2017-12-11 21:14:05 +03:00
|
|
|
var urlService = require('../../services/url'),
|
2017-08-03 14:48:39 +03:00
|
|
|
getContextObject = require('./context_object.js'),
|
2017-12-11 21:14:05 +03:00
|
|
|
_ = require('lodash');
|
2017-08-03 14:48:39 +03:00
|
|
|
|
|
|
|
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) {
|
2017-12-11 21:14:05 +03:00
|
|
|
return urlService.utils.urlFor('image', {image: contextObject.twitter_image}, true);
|
2017-08-03 14:48:39 +03:00
|
|
|
} else if (contextObject.feature_image) {
|
2017-12-11 21:14:05 +03:00
|
|
|
return urlService.utils.urlFor('image', {image: contextObject.feature_image}, true);
|
2017-08-03 14:48:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = getTwitterImage;
|