summaryrefslogtreecommitdiff
path: root/app/blog
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2015-07-10 10:13:58 -0400
committerluxagraf <sng@luxagraf.net>2015-07-10 10:13:58 -0400
commit68361e252c5fae432e30bb88ce86b3d9ac073f28 (patch)
treef8cc1df5ee8f67297d1a096459d7622abae5536f /app/blog
parent66e3ed2c34a8e751eb200b9c8e3c593208a2afa2 (diff)
added more images to facebook OG tags
Diffstat (limited to 'app/blog')
-rw-r--r--app/blog/models.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/app/blog/models.py b/app/blog/models.py
index 513ce05..fbbf1db 100644
--- a/app/blog/models.py
+++ b/app/blog/models.py
@@ -9,7 +9,7 @@ from django import forms
import markdown
from photos.models import PhotoGallery
from locations.models import Location
-
+from bs4 import BeautifulSoup
def get_upload_path(self, filename):
return "images/post-images/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
@@ -19,10 +19,17 @@ def get_tn_path(self, filename):
return "images/post-thumbnail/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename)
-def image_url_replace(str):
- str = str.replace('[[base_url]]', settings.IMAGES_URL)
- return str
+def image_url_replace(s):
+ s = s.replace('[[base_url]]', settings.IMAGES_URL)
+ return s
+def extract_images(s):
+ soup = BeautifulSoup(s)
+ imgs = []
+ for img in soup.find_all('img'):
+ print(img['src'])
+ imgs.append(img['src'])
+ return imgs
class PostImage(models.Model):
title = models.CharField(max_length=100)
@@ -110,6 +117,9 @@ class Entry(models.Model):
img = os.path.splitext(img)[0]
return '/media/images/home-images/hero%s_sm.jpg' % (img)
+ def get_images(self):
+ return extract_images(self.body_html)
+
@property
def state(self):
return self.location.state