summaryrefslogtreecommitdiff
path: root/app/media/models.py
diff options
context:
space:
mode:
authorlxf <sng@luxagraf.net>2020-12-21 14:35:36 -0500
committerlxf <sng@luxagraf.net>2020-12-21 14:35:36 -0500
commit70e09b7c5264da8f8f845a374028f6f02c1cef05 (patch)
tree06937cd0032420e034b93c74df181e990bd29e1e /app/media/models.py
parenteab51d9c70391fd6c4840bfc44aa53aed4b48410 (diff)
fixed a bug in src and srcset functions on luximage
Diffstat (limited to 'app/media/models.py')
-rw-r--r--app/media/models.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/media/models.py b/app/media/models.py
index b9437f1..d7b79c6 100644
--- a/app/media/models.py
+++ b/app/media/models.py
@@ -122,7 +122,7 @@ class LuxImage(models.Model):
def get_image_filename(self):
return os.path.basename(self.image.path)
- @cached_property
+ @property
def get_srcset(self):
srcset = ""
length = len(self.sizes.all())
@@ -135,13 +135,14 @@ class LuxImage(models.Model):
loopnum = loopnum+1
return srcset
- @cached_property
+ @property
def get_src(self):
src = ""
if self.sizes.all().count() > 1:
- src += "%s%s/%s_%s.%s" % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), self.image_name, 'picwide-med', self.image_ext)
+ src = self.get_image_url_by_size('picwide-med')
else:
- src += "%s%s/%s_%s.%s" % (settings.IMAGES_URL, self.pub_date.strftime("%Y"), self.image_name, [size.name for size in self.sizes.all()], self.image_ext)
+ size = "".join(size.name for size in self.sizes.all())
+ src = self.get_image_url_by_size(size)
return src
def get_image_url_by_size(self, size="original"):