Ghost/core/server/data/meta/cover_image.js
Katharina Irrgang 76bd4fdef6 🙀 Image field naming & new img_url helper (#8364)
* 🙀  change database schema for images
    - rename user/post/tag images
    - contains all the required changes from the schema change

* Refactor helper/meta data
    - rename cover to cover_image
    - also rename default settings to match the pattern
    - rename image to profile_image for user
    - rename image to feature_image for tags/posts

* {{image}} >>> {{img_url}}
    - rename
    - change the functionality
    - attr is required
    - e.g. {{img_url feature_image}}

* gscan 1.0.0
    - update yarn.lock

* Update casper reference: 1.0-changes
    - see 5487b4da8d
2017-04-24 18:21:47 +01:00

22 lines
713 B
JavaScript

var utils = require('../../utils'),
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 utils.url.urlFor('image', {image: contextObject.cover_image}, true);
}
} else {
if (contextObject.feature_image) {
return utils.url.urlFor('image', {image: contextObject.feature_image}, true);
}
}
return null;
}
module.exports = getCoverImage;