fallback if thumbnail not present

This commit is contained in:
Morgan McMillian 2021-02-24 20:36:16 -08:00
parent 0d8cbf6755
commit 6dc0c2c367

View file

@ -502,9 +502,14 @@ class PostItem(Gtk.ListBoxRow):
return scaled_img return scaled_img
def get_oembed_thumb(self, oembed): def get_oembed_thumb(self, oembed):
url = oembed.thumbnail_url if 'thumbnail_url' in oembed:
old_width = oembed.thumbnail_width url = oembed.thumbnail_url
old_height = oembed.thumbnail_height old_width = oembed.thumbnail_width
old_height = oembed.thumbnail_height
else:
url = oembed.url
old_width = oembed.width
old_height = oembed.height
ratio = old_width / old_height ratio = old_width / old_height
new_height = 256 / ratio new_height = 256 / ratio
r = requests.get(url) r = requests.get(url)