From 99b5f9544e8ceaf5eca878a3fcda05d4f7441628 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 27 Dec 2020 19:23:32 +0100 Subject: [PATCH] Extract resize height and width to env variables & switch to 750px width --- articles/static/public.css | 3 ++- attachments/models.py | 4 ++-- blog/settings.py | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/articles/static/public.css b/articles/static/public.css index 0e0f28a..b2c00a2 100644 --- a/articles/static/public.css +++ b/articles/static/public.css @@ -1,5 +1,6 @@ body { - max-width: 640px; + /* Overriding so that it doesn't change even when updating the library. */ + max-width: 750px; } footer { diff --git a/attachments/models.py b/attachments/models.py index 81c8da3..5e93cf0 100644 --- a/attachments/models.py +++ b/attachments/models.py @@ -64,8 +64,8 @@ class Attachment(models.Model): post_data = { "lossy": 1, "resize": 3, - "resize_width": 640, - "resize_height": 10000, + "resize_width": settings.SHORTPIXEL_RESIZE_WIDTH, + "resize_height": settings.SHORTPIXEL_RESIZE_HEIGHT, "keep_exif": 1, "file_paths": json.dumps( [f"{self.original_file.name}:{self.original_file.path}"] diff --git a/blog/settings.py b/blog/settings.py index a0d7901..0feffc9 100644 --- a/blog/settings.py +++ b/blog/settings.py @@ -187,6 +187,8 @@ BLOG = { } SHORTPIXEL_API_KEY = os.getenv("SHORTPIXEL_API_KEY") +SHORTPIXEL_RESIZE_WIDTH = int(os.getenv("SHORTPIXEL_RESIZE_WIDTH", 750)) +SHORTPIXEL_RESIZE_HEIGHT = int(os.getenv("SHORTPIXEL_RESIZE_HEIGHT", 10000)) PLAUSIBLE_DOMAIN = os.getenv("PLAUSIBLE_DOMAIN")