summaryrefslogtreecommitdiff
path: root/app/posts
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-11-15 13:30:42 -0500
committerluxagraf <sng@luxagraf.net>2020-11-15 13:30:42 -0500
commit8da2f3bd3c00f36290c017a45b7453e466ee3666 (patch)
tree2d34092c0acda8d45ea65180ab79bdc38c433235 /app/posts
parent7509da286bccd1dda358507cd455f9297db59247 (diff)
added legacy image function to posts to handle jrnls without a featured
image
Diffstat (limited to 'app/posts')
-rw-r--r--app/posts/models.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/posts/models.py b/app/posts/models.py
index c686070..d0e8c0b 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -162,6 +162,16 @@ class Post(models.Model):
else:
return 0.7
+ def get_image_url(self):
+ '''
+ for legacy jrnl posts without a featured_image
+ '''
+ try:
+ image_dir, img = self.old_image.url.split('post-images/')[1].split('/')
+ return '%spost-images/%s/%s' % (settings.IMAGES_URL, image_dir, img)
+ except ValueError:
+ pass
+
def save(self, *args, **kwargs):
created = self.pk is None
if not created: