summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-20 17:49:35 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-20 17:49:35 +0100
commit0527e33e8733d5fe92a2f732f9529269cc5aba9a (patch)
treeb6ee2d0e12d79dfbe151c01e6282a9c8d8063fe6
parent954ce5dc30faf9bebfd060689d4fd8f8c147ce7f (diff)
downloadChimère-0527e33e8733d5fe92a2f732f9529269cc5aba9a.tar.bz2
Chimère-0527e33e8733d5fe92a2f732f9529269cc5aba9a.zip
OpenGraph: no empty description - image width and image height
-rw-r--r--chimere/templates/base.html17
-rw-r--r--chimere/views.py4
-rw-r--r--settings.py5
3 files changed, 25 insertions, 1 deletions
diff --git a/chimere/templates/base.html b/chimere/templates/base.html
index 286ae88..4e87e44 100644
--- a/chimere/templates/base.html
+++ b/chimere/templates/base.html
@@ -14,16 +14,33 @@
<meta property="og:url" content="{{current_site}}{% if tiny %}/ty/{{tiny}}{% endif %}" />
{% if current_feature.image %}
<meta property="og:image" content="{{current_site}}{{current_feature.image.picture.url}}" />
+ <meta property="og:image:width"
+ content="{{current_feature.image.picture.width}}" />
+ <meta property="og:image:height"
+ content="{{current_feature.image.picture.height}}" />
{% elif PROJECT_IMAGE %}
<meta property="og:image" content="{{PROJECT_IMAGE}}" />
+ <meta property="og:image:width"
+ content="{{PROJECT_IMAGE_WIDTH}}" />
+ <meta property="og:image:height"
+ content="{{PROJECT_IMAGE_HEIGHT}}" />
{% endif %}
+ {% if current_feature.text_description %}
<meta property="og:description"
content="{{current_feature.text_description|cut:'"'}}" />
{% else %}
+ <meta property="og:description" content=" - " />
+ {% endif %}
+ {% else %}
<meta property="og:url" content="{{current_site}}" />
{% if PROJECT_IMAGE %}
<meta property="og:image" content="{{PROJECT_IMAGE}}" />
+ <meta property="og:image:width"
+ content="{{PROJECT_IMAGE_WIDTH}}" />
+ <meta property="og:image:height"
+ content="{{PROJECT_IMAGE_HEIGHT}}" />
{% endif %}
+ <meta property="og:description" content=" - " />
{% endif %}
{% endblock %}
diff --git a/chimere/views.py b/chimere/views.py
index f2bc5fc..919824a 100644
--- a/chimere/views.py
+++ b/chimere/views.py
@@ -213,6 +213,10 @@ def index(request, area_name=None, default_area=None, simple=False,
})
if hasattr(settings, 'PROJECT_IMAGE') and settings.PROJECT_IMAGE:
response_dct['PROJECT_IMAGE'] = settings.PROJECT_IMAGE
+ if hasattr(settings, 'PROJECT_IMAGE_WIDTH'):
+ response_dct['PROJECT_IMAGE_WIDTH'] = settings.PROJECT_IMAGE_WIDTH
+ if hasattr(settings, 'PROJECT_IMAGE_HEIGHT'):
+ response_dct['PROJECT_IMAGE_HEIGHT'] = settings.PROJECT_IMAGE_HEIGHT
if hasattr(settings, 'CONTACT_EMAIL') and settings.CONTACT_EMAIL:
response_dct['contact_email'] = settings.CONTACT_EMAIL
response_dct['share_networks'], net_dct = \
diff --git a/settings.py b/settings.py
index 0ab3a23..ec67e5a 100644
--- a/settings.py
+++ b/settings.py
@@ -13,12 +13,15 @@ MOBILE_TEST = False
DEBUG_TOOLBAR = False
SQL_DEBUG = False
+ROOT_PATH = os.path.realpath(os.path.dirname(__file__)) + "/"
# Django settings for chimere project.
PROJECT_NAME = 'Chimere'
# url of the project image
PROJECT_IMAGE = ''
-ROOT_PATH = os.path.realpath(os.path.dirname(__file__)) + "/"
+# mandatory if you put an image
+PROJECT_IMAGE_WIDTH = 0
+PROJECT_IMAGE_HEIGHT = 0
EMAIL_HOST = 'localhost'
CONTACT_EMAIL = ''