From 8da2f3bd3c00f36290c017a45b7453e466ee3666 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sun, 15 Nov 2020 13:30:42 -0500 Subject: added legacy image function to posts to handle jrnls without a featured image --- app/posts/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app') 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: -- cgit v1.2.3-70-g09d2