Ghost/core/server/helpers/image.js
cobbspur 4a56d10c86 Created image helper with absolute url option
closes #4231

- Adds {{image}} helper
- Adds image_spec test unit
- Updated {{ghost_head}} to use image helper
2014-10-28 13:14:41 +02:00

21 lines
594 B
JavaScript

// Usage: `{{image}}`, `{{image absolute="true"}}`
//
// Returns the URL for the current object scope i.e. If inside a post scope will return image permalink
// `absolute` flag outputs absolute URL, else URL is relative.
var Promise = require('bluebird'),
config = require('../config'),
image;
image = function (options) {
var absolute = options && options.hash.absolute;
if (this.image) {
return Promise.resolve(config.urlFor('image', {image: this.image}, absolute));
} else {
return Promise.resolve();
}
};
module.exports = image;