From 043496182952af6c9079660e37c9c7590c46d54e Mon Sep 17 00:00:00 2001 From: jedi Date: Wed, 13 Dec 2023 00:54:59 +0100 Subject: [PATCH] stash --- core/files/media_v2.py | 8 +++-- web/src/components/AuthenticatedImage.vue | 39 +++++++++++++++++++++++ web/src/components/Lightbox.vue | 4 +-- web/src/store/index.js | 11 ++++--- web/src/views/Items.vue | 9 +++--- 5 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 web/src/components/AuthenticatedImage.vue 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 @@