From f0d229c42396056190a1ea71303e7bdc08b9b5d6 Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Mon, 6 May 2024 15:42:12 +1200 Subject: [PATCH] use smaller versions of lemmy images #159 --- app/models.py | 7 +++++-- app/templates/post/_post_full.html | 4 ++-- app/templates/post/_post_teaser_masonry.html | 7 +------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/models.py b/app/models.py index 6b49fb8d..a84b5c02 100644 --- a/app/models.py +++ b/app/models.py @@ -204,9 +204,12 @@ class File(db.Model): thumbnail_width = db.Column(db.Integer) thumbnail_height = db.Column(db.Integer) - def view_url(self): + def view_url(self, resize=False): if self.source_url: - return self.source_url + if resize and '/pictrs/' in self.source_url and '?' not in self.source_url: + return f'{self.source_url}?thumbnail=1024' + else: + return self.source_url elif self.file_path: file_path = self.file_path[4:] if self.file_path.startswith('app/') else self.file_path return f"https://{current_app.config['SERVER_NAME']}/{file_path}" diff --git a/app/templates/post/_post_full.html b/app/templates/post/_post_full.html index a5b1bcce..631a50c3 100644 --- a/app/templates/post/_post_full.html +++ b/app/templates/post/_post_full.html @@ -32,10 +32,10 @@