Ghost/core/frontend/meta/cover_image.js
Vikas Potluri 1bd8c18a16
Moved core/server/lib/url-utils to core/shared/url-utils (#11856)
* moved url-utils from server to shared
* updated imports of url-utils
2020-05-28 11:57:02 +01:00

22 lines
709 B
JavaScript

const urlUtils = require('../../shared/url-utils');
const getContextObject = require('./context_object.js');
const _ = require('lodash');
function getCoverImage(data) {
const context = data.context ? data.context : null;
const contextObject = getContextObject(data, context);
if (_.includes(context, 'home') || _.includes(context, 'author')) {
if (contextObject.cover_image) {
return urlUtils.urlFor('image', {image: contextObject.cover_image}, true);
}
} else {
if (contextObject.feature_image) {
return urlUtils.urlFor('image', {image: contextObject.feature_image}, true);
}
}
return null;
}
module.exports = getCoverImage;