From 6fc3103aefc5d64e65286ffd09e3d09a11631687 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 24 Mar 2014 20:43:24 -0400 Subject: [PATCH] topic og:image changes --- src/controllers/topics.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/controllers/topics.js b/src/controllers/topics.js index a793452e16..9ef73652ab 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -66,14 +66,19 @@ topicsController.get = function(req, res, next) { description = validator.escape(description); - var ogImageUrl = meta.config['brand:logo']; - if(ogImageUrl && ogImageUrl.indexOf('http') === -1) { - ogImageUrl = nconf.get('url') + ogImageUrl; + var ogImageUrl = ''; + if (topicData.thumb) { + ogImageUrl = topicData.thumb; + } else if(topicData.posts.length && topicData.posts[0].user && topicData.posts[0].user.picture){ + ogImageUrl = topicData.posts[0].user.picture; + } else if(meta.config['brand:logo']) { + ogImageUrl = meta.config['brand:logo']; + } else { + ogImageUrl = '/logo.png'; } - var userPicture = ''; - if (topicData.posts.length && topicData.posts[0].user) { - userPicture = topicData.posts[0].user.picture; + if (ogImageUrl.indexOf('http') === -1) { + ogImageUrl = nconf.get('url') + ogImageUrl; } res.locals.metaTags = [ @@ -102,12 +107,12 @@ topicsController.get = function(req, res, next) { content: nconf.get('url') + '/topic/' + topicData.slug }, { - property: "og:image:url", + property: 'og:image', content: ogImageUrl }, { - property: 'og:image', - content: userPicture + property: "og:image:url", + content: ogImageUrl }, { property: "article:published_time",