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", &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)
@ -234,6 +237,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()),