mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
4265afe580
refs #9178 - we have to take care that we don't end up in circular dependencies - e.g. API requires UrlService and UrlService needs to require the API (for requesting data) - update the references - we would like to get rid of the utils folder, this is/was the most complicated change
22 lines
713 B
JavaScript
22 lines
713 B
JavaScript
var urlService = require('../../services/url'),
|
|
getContextObject = require('./context_object.js'),
|
|
_ = require('lodash');
|
|
|
|
function getCoverImage(data) {
|
|
var context = data.context ? data.context : null,
|
|
contextObject = getContextObject(data, context);
|
|
|
|
if (_.includes(context, 'home') || _.includes(context, 'author')) {
|
|
if (contextObject.cover_image) {
|
|
return urlService.utils.urlFor('image', {image: contextObject.cover_image}, true);
|
|
}
|
|
} else {
|
|
if (contextObject.feature_image) {
|
|
return urlService.utils.urlFor('image', {image: contextObject.feature_image}, true);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
module.exports = getCoverImage;
|