mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
topic og:image changes
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user