diff --git a/src/utils.rs b/src/utils.rs index 56a7de7..52aec95 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -134,8 +134,10 @@ impl Media { } else if data["is_gallery"].as_bool().unwrap_or_default() { // If this post contains a gallery of images gallery = GalleryMedia::parse(&data["gallery_data"]["items"], &data["media_metadata"]); - ("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 { // If type can't be determined, return url ("link", &data["url"], None) @@ -150,6 +152,8 @@ impl Media { Self { url: format_url(url_val.as_str().unwrap_or_default()), 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(), height: source["height"].as_i64().unwrap_or_default(), poster: format_url(source["url"].as_str().unwrap_or_default()), diff --git a/templates/post.html b/templates/post.html index add5881..1be850c 100644 --- a/templates/post.html +++ b/templates/post.html @@ -69,15 +69,7 @@ {% if post.post_type == "image" %} - - - - Post image - - + Post image {% else if post.post_type == "video" || post.post_type == "gif" %} {% if prefs.use_hls == "on" && !post.media.alt_url.is_empty() %} diff --git a/templates/utils.html b/templates/utils.html index a11583f..8f4caa2 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -94,16 +94,8 @@

{% if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "image" %} - - - - - Post image - - + + Post image {% else if (prefs.layout.is_empty() || prefs.layout == "card") && post.post_type == "gif" %}