thumbnails: Set og:image on links with thumbnails.

This commit is contained in:
Andre D
2014-03-31 14:50:11 -04:00
committed by Neil Williams
parent f8ffa3810d
commit 36bb6298db
2 changed files with 9 additions and 1 deletions

View File

@@ -181,7 +181,9 @@ class Reddit(Templated):
infotext='', content=None, short_description='', title='',
robots=None, show_sidebar=True, show_chooser=False,
footer=True, srbar=True, page_classes=None, short_title=None,
show_wiki_actions=False, extra_js_config=None, **context):
show_wiki_actions=False, extra_js_config=None,
meta_thumbnail=None,
**context):
Templated.__init__(self, **context)
self.title = title
self.short_title = short_title
@@ -193,6 +195,7 @@ class Reddit(Templated):
self.loginbox = True
self.show_sidebar = show_sidebar
self.space_compress = space_compress
self.meta_thumbnail = meta_thumbnail
# instantiate a footer
self.footer = RedditFooter() if footer else None
self.debug_footer = DebugFooter()
@@ -1249,6 +1252,8 @@ class LinkInfoPage(Reddit):
title = strings.permalink_title % params
short_description = _truncate(comment.body.strip(), MAX_DESCRIPTION_LENGTH) if comment.body else None
if self.link.has_thumbnail and self.link.thumbnail:
kw['meta_thumbnail'] = self.link.thumbnail
self.subtitle = subtitle

View File

@@ -33,6 +33,9 @@
<title>${self.Title()}</title>
<meta name="keywords" content="${self.keywords()}" />
<meta name="description" content="${getattr(thing, 'short_description', None) or g.short_description}" />
%if getattr(thing, 'meta_thumbnail', None):
<meta name="og:image" content="${thing.meta_thumbnail}">
%endif
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
${self.viewport()}
${self.robots()}