src/pyams_default_theme/shared/site/__init__.py
changeset 385 e0f8d5d0e31e
parent 379 240417d006df
child 388 f5521cdc0207
--- a/src/pyams_default_theme/shared/site/__init__.py	Fri Jan 18 15:43:57 2019 +0100
+++ b/src/pyams_default_theme/shared/site/__init__.py	Fri Jan 18 18:07:39 2019 +0100
@@ -110,6 +110,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)
@@ -140,13 +141,16 @@
         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')
         yield ContentMeta('twitter:title', i18n.query_attribute('title', lang=lang, request=request))
         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
         yield SchemaMeta('name', i18n.query_attribute('title', lang=lang, request=request))