webp thumbnail support with png fallback

This commit is contained in:
Michael Shamoon committed 2022-06-10 02:28:13 -07:00
1 parent e4a26164de
commit 58f2c6a5fc
3 files changed
+15 -5

No files matched your search

+6 -1
View File
@@ -362,7 +362,12 @@ class DocumentViewSet(
handle = doc.thumbnail_file
# TODO: Send ETag information and use that to send new thumbnails
# if available
return HttpResponse(handle, content_type="image/png")
content_type = (
"image/webp"
if os.path.splitext(doc.thumbnail_path)[1] == ".webp"
else "image/png"
)
return HttpResponse(handle, content_type=content_type)
except (FileNotFoundError, Document.DoesNotExist):
raise Http404()