Merge remote-tracking branch 'origin/pull/738'

This commit is contained in:
Matthew Esposito 2023-12-26 15:51:15 -05:00
commit d76051302e
No known key found for this signature in database
2 changed files with 16 additions and 1 deletions

View File

@ -220,6 +220,9 @@ impl Media {
gallery = GalleryMedia::parse(&data["gallery_data"]["items"], &data["media_metadata"]); gallery = GalleryMedia::parse(&data["gallery_data"]["items"], &data["media_metadata"]);
("gallery", &data["url"], None) ("gallery", &data["url"], None)
} else if data["is_reddit_media_domain"].as_bool().unwrap_or_default() && data["domain"] == "i.redd.it" {
// If this post contains a reddit media (image) URL.
("image", &data["url"], None)
} else { } else {
// If type can't be determined, return url // If type can't be determined, return url
("link", &data["url"], None) ("link", &data["url"], None)
@ -234,6 +237,8 @@ impl Media {
Self { Self {
url: format_url(url_val.as_str().unwrap_or_default()), url: format_url(url_val.as_str().unwrap_or_default()),
alt_url, alt_url,
// Note: in the data["is_reddit_media_domain"] path above
// width and height will be 0.
width: source["width"].as_i64().unwrap_or_default(), width: source["width"].as_i64().unwrap_or_default(),
height: source["height"].as_i64().unwrap_or_default(), height: source["height"].as_i64().unwrap_or_default(),
poster: format_url(source["url"].as_str().unwrap_or_default()), poster: format_url(source["url"].as_str().unwrap_or_default()),

View File

@ -100,6 +100,10 @@
{% if post.post_type == "image" %} {% if post.post_type == "image" %}
<div class="post_media_content"> <div class="post_media_content">
<a href="{{ post.media.url }}" class="post_media_image" > <a href="{{ post.media.url }}" class="post_media_image" >
{% if post.media.height == 0 || post.media.width == 0 %}
<!-- i.redd.it images speical case -->
<img width="100%" height="100%" loading="lazy" alt="Post image" src="{{ post.media.url }}"/>
{% else %}
<svg <svg
width="{{ post.media.width }}px" width="{{ post.media.width }}px"
height="{{ post.media.height }}px" height="{{ post.media.height }}px"
@ -109,6 +113,7 @@
<img loading="lazy" alt="Post image" src="{{ post.media.url }}"/> <img loading="lazy" alt="Post image" src="{{ post.media.url }}"/>
</desc> </desc>
</svg> </svg>
{% endif %}
</a> </a>
</div> </div>
{% else if post.post_type == "video" || post.post_type == "gif" %} {% else if post.post_type == "video" || post.post_type == "gif" %}
@ -222,7 +227,11 @@
<!-- POST MEDIA/THUMBNAIL --> <!-- POST MEDIA/THUMBNAIL -->
{% if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "image" %} {% if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "image" %}
<div class="post_media_content"> <div class="post_media_content">
<a href="{{ post.media.url }}" class="post_media_image {% if post.media.height / post.media.width < 2 %}short{% endif %}" > <a href="{{ post.media.url }}" class="post_media_image {% if post.media.height < post.media.width*2 %}short{% endif %}" >
{% if post.media.height == 0 || post.media.width == 0 %}
<!-- i.redd.it images speical case -->
<img width="100%" height="100%" loading="lazy" alt="Post image" src="{{ post.media.url }}"/>
{% else %}
<svg <svg
{%if post.flags.nsfw && prefs.blur_nsfw=="on" %}class="post_nsfw_blur"{% endif %} {%if post.flags.nsfw && prefs.blur_nsfw=="on" %}class="post_nsfw_blur"{% endif %}
width="{{ post.media.width }}px" width="{{ post.media.width }}px"
@ -233,6 +242,7 @@
<img loading="lazy" alt="Post image" src="{{ post.media.url }}"/> <img loading="lazy" alt="Post image" src="{{ post.media.url }}"/>
</desc> </desc>
</svg> </svg>
{% endif %}
</a> </a>
</div> </div>
{% else if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "gif" %} {% else if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "gif" %}