diff --git a/core/files/media_v2.py b/core/files/media_v2.py index 2e8661d..7dd784d 100644 --- a/core/files/media_v2.py +++ b/core/files/media_v2.py @@ -39,10 +39,14 @@ def thumbnail_urls(request, size, hash): from PIL import Image image = Image.open(file.file) image.thumbnail((size, size)) - image.save(MEDIA_ROOT + f'/media/thumbnails/{size}/{hash_path}', quality=90) + rgb_image = image.convert('RGB') + thumb_dir = os.path.dirname(MEDIA_ROOT + f'/thumbnails/{size}/{hash_path}') + if not os.path.exists(thumb_dir): + os.makedirs(thumb_dir) + rgb_image.save(MEDIA_ROOT + f'/thumbnails/{size}/{hash_path}', 'jpeg', quality=90) return HttpResponse(status=status.HTTP_200_OK, - content_type=file.mime_type, + content_type="image/jpeg", headers={ 'X-Accel-Redirect': f'/redirect_thumbnail/{size}/{hash_path}', 'Access-Control-Allow-Origin': '*', diff --git a/web/src/components/AuthenticatedImage.vue b/web/src/components/AuthenticatedImage.vue new file mode 100644 index 0000000..67a64c6 --- /dev/null +++ b/web/src/components/AuthenticatedImage.vue @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file diff --git a/web/src/components/Lightbox.vue b/web/src/components/Lightbox.vue index b1933bb..2dae0de 100644 --- a/web/src/components/Lightbox.vue +++ b/web/src/components/Lightbox.vue @@ -1,12 +1,12 @@