diff options
Diffstat (limited to 'app/jrnl/models.py')
-rw-r--r-- | app/jrnl/models.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py index ceaefa6..2fc775e 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -37,15 +37,16 @@ def image_url_replace(s): def parse_image(s): soup = BeautifulSoup(s.group(), "lxml") for img in soup.find_all('img'): - print(img) src = img['src'].split("images/")[1] - print(src) i = LuxImage.objects.get(image__icontains=src) cl = img['class'] caption = False exif = False + cluster_class = None if len(cl) > 1: css_class = cl[0] + if css_class == 'cluster': + cluster_class = cl[1] if cl[1] == 'caption': caption = True if cl[1] == 'exif': @@ -59,7 +60,7 @@ def parse_image(s): print('caption'+str(caption)) else: css_class = cl[0] - c = Context({'image': i, 'caption': caption, 'exif': exif}) + c = Context({'image': i, 'caption': caption, 'exif': exif, 'cluster_class': cluster_class}) return render_to_string("lib/img_%s.html" % css_class, c) @@ -72,7 +73,10 @@ def extract_images(s): soup = BeautifulSoup(s, "lxml") imgs = [] for img in soup.find_all('img'): - imgs.append(img['src']) + try: + imgs.append(img['src']) + except: + pass return imgs |