src/pyams_default_theme/root/opengraph.py
changeset 385 e0f8d5d0e31e
parent 379 240417d006df
child 388 f5521cdc0207
--- a/src/pyams_default_theme/root/opengraph.py	Fri Jan 18 15:43:57 2019 +0100
+++ b/src/pyams_default_theme/root/opengraph.py	Fri Jan 18 18:07:39 2019 +0100
@@ -59,6 +59,7 @@
         # illustration properties
         registry = request.registry
         thumbnail = None
+        alt = None
         illustration = registry.queryAdapter(context, IIllustration, name='link')
         if (illustration is None) or (not illustration.has_data()):
             illustration = registry.queryAdapter(context, IIllustration)
@@ -89,14 +90,17 @@
         if (share_info is not None) and share_info.twitter_account:
             yield ContentMeta('twitter:site', share_info.twitter_account)
             yield ContentMeta('twitter:creator', share_info.twitter_creator_account or share_info.twitter_account)
-        if illustration is not None:
-            yield ContentMeta('twitter:card', 'summary_large_image')
-        else:
-            yield ContentMeta('twitter:card', 'summary')
         if title:
             yield ContentMeta('twitter:title', title)
         if description:
             yield ContentMeta('twitter:description', description)
+        if thumbnail is not None:
+            yield ContentMeta('twitter:card', 'summary_large_image')
+            yield ContentMeta('twitter:image', absolute_url(thumbnail, request))
+            if alt:
+                yield ContentMeta('twitter:image:alt', alt)
+        else:
+            yield ContentMeta('twitter:card', 'summary')
 
         # Schema.org properties
         if title: