Skip to content

Commit

Permalink
Since max, default to smallest.
Browse files Browse the repository at this point in the history
  • Loading branch information
markpbaggett committed Dec 17, 2024
1 parent aed113a commit daf26ae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion iiif_prezi3/helpers/add_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def create_thumbnail_from_iiif(self, url, preferred_width=500, **kwargs):
if 'sizes' in image_info:
best_fit_size = max(
(size for size in image_info['sizes'] if size["width"] <= preferred_width),
key=lambda size: size["width"]
key=lambda size: size["width"],
default=image_info['sizes'][0]
)
thumbnail_id = f"{url.replace('/info.json', '')}/full/{best_fit_size['width']},{best_fit_size['height']}/0/default.jpg"
else:
Expand Down

0 comments on commit daf26ae

Please sign in to comment.