mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
21 lines
734 B
JavaScript
21 lines
734 B
JavaScript
|
var utils = require('../../utils'),
|
||
|
getContextObject = require('./context_object.js'),
|
||
|
_ = require('lodash');
|
||
|
|
||
|
function getTwitterImage(data) {
|
||
|
var context = data.context ? data.context : null,
|
||
|
contextObject = getContextObject(data, context);
|
||
|
|
||
|
if (_.includes(context, 'post') || _.includes(context, 'page') || _.includes(context, 'amp')) {
|
||
|
if (contextObject.twitter_image) {
|
||
|
return utils.url.urlFor('image', {image: contextObject.twitter_image}, true);
|
||
|
} else if (contextObject.feature_image) {
|
||
|
return utils.url.urlFor('image', {image: contextObject.feature_image}, true);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
module.exports = getTwitterImage;
|