thumbnail and overview
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user