diff libervia/pages/photos/album/_browser/__init__.py @ 1330:b525fdcb393b

browser (photos/album): used biggest thumbnails instead of original image for slideshow: biggest thumbnail should be adapted to fullscreen slideshow, and it's better to use than original image which may have a size of several megabytes.
author Goffi <goffi@goffi.org>
date Fri, 14 Aug 2020 09:31:32 +0200
parents 0cbf86b1dcca
children fe353fceec38
line wrap: on
line diff
--- a/libervia/pages/photos/album/_browser/__init__.py	Fri Aug 14 09:31:32 2020 +0200
+++ b/libervia/pages/photos/album/_browser/__init__.py	Fri Aug 14 09:31:32 2020 +0200
@@ -161,7 +161,13 @@
     slideshow.attach()
     for idx, item_elt in enumerate(document.select('.item')):
         item = JSON.parse(item_elt.dataset.item)
-        slideshow.add_slide(html.IMG(src=item['url'], Class="slide_img"), item)
+        try:
+            biggest_thumb = item['extra']['thumbnails'][-1]
+            thumb_url = f"{cache_path}{biggest_thumb['filename']}"
+        except (KeyError, IndexError) as e:
+            print(f"Can't get full screen thumbnail URL: {e}")
+            thumb_url = item['url']
+        slideshow.add_slide(html.IMG(src=thumb_url, Class="slide_img"), item)
         if item_elt == clicked_item_elt:
             slideshow.index = idx