thumbnail and overview

This commit is contained in:
Ross
2025-04-14 10:39:08 +01:00
parent edf4a992de
commit eea61fc99c
7 changed files with 52 additions and 10 deletions
+23
View File
@@ -231,6 +231,29 @@ class QuestionBase(models.Model, AuthorMixin, QuestionMixin):
return False
def get_thumbnail(self, recreate=False, fail_loudly=False):
images = self.images.all()
if len(images) < 1:
return "No images", 0
img = findMiddle(images).image
try:
thumbnailer = get_thumbnailer(img)
if recreate:
thumbnailer.delete_thumbnails()
thumbnail = thumbnailer["exam-list"]
except InvalidImageFormatError as e:
if fail_loudly:
raise e
return format_html(
'<img title="{}" src="/static/not-found-image.jpg" />', img
), len(images)
return format_html('<span style="border: 1px solid;"><img src="/media/{}" /></span>', thumbnail), len(images)
class SeriesImageBase(models.Model):
"""