0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00
ghost/core/server/data/meta/cover_image.js

21 lines
623 B
JavaScript
Raw Normal View History

var config = require('../../config'),
getContextObject = require('./context_object.js');
function getCoverImage(data) {
var context = data.context ? data.context[0] : null,
contextObject = getContextObject(data, context);
if (context === 'home' || context === 'author') {
if (contextObject.cover) {
return config.urlFor('image', {image: contextObject.cover}, true);
}
} else {
if (contextObject.image) {
return config.urlFor('image', {image: contextObject.image}, true);
}
}
return null;
}
module.exports = getCoverImage;