topic og:image changes

v1.18.x
barisusakli 11 years ago
parent fc1cb76444
commit 6fc3103aef

@ -66,14 +66,19 @@ topicsController.get = function(req, res, next) {
description = validator.escape(description); description = validator.escape(description);
var ogImageUrl = meta.config['brand:logo']; var ogImageUrl = '';
if(ogImageUrl && ogImageUrl.indexOf('http') === -1) { if (topicData.thumb) {
ogImageUrl = nconf.get('url') + ogImageUrl; 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 (ogImageUrl.indexOf('http') === -1) {
if (topicData.posts.length && topicData.posts[0].user) { ogImageUrl = nconf.get('url') + ogImageUrl;
userPicture = topicData.posts[0].user.picture;
} }
res.locals.metaTags = [ res.locals.metaTags = [
@ -102,12 +107,12 @@ topicsController.get = function(req, res, next) {
content: nconf.get('url') + '/topic/' + topicData.slug content: nconf.get('url') + '/topic/' + topicData.slug
}, },
{ {
property: "og:image:url", property: 'og:image',
content: ogImageUrl content: ogImageUrl
}, },
{ {
property: 'og:image', property: "og:image:url",
content: userPicture content: ogImageUrl
}, },
{ {
property: "article:published_time", property: "article:published_time",

Loading…
Cancel
Save