Thumbnails: fix default size definition in template utility

This commit is contained in:
Joachim 2021-08-20 18:06:09 +02:00 committed by GitHub
parent 7a390af07e
commit bf6ee9f53c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,6 +56,8 @@ def truncatepath(value, arg):
@register.simple_tag(takes_context=False)
def get_book_cover_thumbnail(book, size="medium", ext="jpg"):
"""Returns a book thumbnail at the specified size and extension, with fallback if needed"""
if size == "":
size = "medium"
try:
cover_thumbnail = getattr(book, "cover_bw_book_%s_%s" % (size, ext))
return cover_thumbnail.url