--- a/src/pyams_default_theme/root/opengraph.py Fri Jun 21 16:16:18 2019 +0200
+++ b/src/pyams_default_theme/root/opengraph.py Wed Jun 26 10:00:20 2019 +0200
@@ -64,19 +64,20 @@
illustration = registry.queryAdapter(context, IIllustration)
if (illustration is not None) and illustration.has_data():
data = II18n(illustration).query_attribute('data', lang=lang, request=request)
- thumbnail = IThumbnails(data).get_thumbnail('800x600')
- yield PropertyMeta('og:image', absolute_url(thumbnail, request))
- if request.scheme == 'https':
- yield PropertyMeta('og:image:secure_url', absolute_url(thumbnail, request))
- else:
- yield PropertyMeta('og:image:url', absolute_url(thumbnail, request))
- yield PropertyMeta('og:image:type', thumbnail.content_type)
- image_size = thumbnail.image_size
- yield PropertyMeta('og:image:width', image_size[0])
- yield PropertyMeta('og:image:height', image_size[1])
- alt = II18n(illustration).query_attribute('alt_title', lang=lang, request=request)
- if alt:
- yield PropertyMeta('og:image:alt', alt)
+ if data:
+ thumbnail = IThumbnails(data).get_thumbnail('800x600')
+ yield PropertyMeta('og:image', absolute_url(thumbnail, request))
+ if request.scheme == 'https':
+ yield PropertyMeta('og:image:secure_url', absolute_url(thumbnail, request))
+ else:
+ yield PropertyMeta('og:image:url', absolute_url(thumbnail, request))
+ yield PropertyMeta('og:image:type', thumbnail.content_type)
+ image_size = thumbnail.image_size
+ yield PropertyMeta('og:image:width', image_size[0])
+ yield PropertyMeta('og:image:height', image_size[1])
+ alt = II18n(illustration).query_attribute('alt_title', lang=lang, request=request)
+ if alt:
+ yield PropertyMeta('og:image:alt', alt)
# locales properties
yield PropertyMeta('og:locale', lang)
--- a/src/pyams_default_theme/shared/common/opengraph.py Fri Jun 21 16:16:18 2019 +0200
+++ b/src/pyams_default_theme/shared/common/opengraph.py Wed Jun 26 10:00:20 2019 +0200
@@ -97,19 +97,20 @@
target = get_parent(target, IIllustrationTarget, allow_context=False)
if (target is not None) and (illustration is not None):
data = II18n(illustration).query_attribute('data', lang=lang, request=request)
- thumbnail = IThumbnails(data).get_thumbnail('800x600')
- yield PropertyMeta('og:image', absolute_url(thumbnail, request))
- if request.scheme == 'https':
- yield PropertyMeta('og:image:secure_url', absolute_url(thumbnail, request))
- else:
- yield PropertyMeta('og:image:url', absolute_url(thumbnail, request))
- yield PropertyMeta('og:image:type', thumbnail.content_type)
- image_size = thumbnail.image_size
- yield PropertyMeta('og:image:width', image_size[0])
- yield PropertyMeta('og:image:height', image_size[1])
- alt = II18n(illustration).query_attribute('alt_title', lang=lang, request=request)
- if alt:
- yield PropertyMeta('og:image:alt', alt)
+ if data:
+ thumbnail = IThumbnails(data).get_thumbnail('800x600')
+ yield PropertyMeta('og:image', absolute_url(thumbnail, request))
+ if request.scheme == 'https':
+ yield PropertyMeta('og:image:secure_url', absolute_url(thumbnail, request))
+ else:
+ yield PropertyMeta('og:image:url', absolute_url(thumbnail, request))
+ yield PropertyMeta('og:image:type', thumbnail.content_type)
+ image_size = thumbnail.image_size
+ yield PropertyMeta('og:image:width', image_size[0])
+ yield PropertyMeta('og:image:height', image_size[1])
+ alt = II18n(illustration).query_attribute('alt_title', lang=lang, request=request)
+ if alt:
+ yield PropertyMeta('og:image:alt', alt)
# locales properties
yield PropertyMeta('og:locale', lang)