mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
a9050f68ea
no issue - Removed deprecated 'blog' reference from frontend data. The alias (site->blog) stays till next version (v4) as it's not leaving much of technical debt but would ease the migration process for anybody still using it. - The follow up to this is substitute of all references to `options.data.blog` with `options.data.site` in "frontend" - Fixed test utils helper to use `site` instead of `blog` - Removed 0.1 flag checks in {{get}} helper - Removed user aliasing from {{get}} helper - Removed unused translation for {{get}} helper - Added a note to excerpt changes in metadata for future reference - Removed page alias used in description helper. The mix of page context with post object in the metadata was only possible in v0.1 - Changed mock in ghost_head helper to use v2 - Removed unneeded test for body class helper
62 lines
2.5 KiB
JavaScript
62 lines
2.5 KiB
JavaScript
var Promise = require('bluebird'),
|
|
_ = require('lodash'),
|
|
imageLib = require('../../server/lib/image');
|
|
|
|
/**
|
|
* Get Image dimensions
|
|
* @param {object} metaData
|
|
* @returns {object} metaData
|
|
* @description for image properties in meta data (coverImage, authorImage and site.logo), `getCachedImageSizeFromUrl` is
|
|
* called to receive image width and height
|
|
*/
|
|
function getImageDimensions(metaData) {
|
|
var fetch = {
|
|
coverImage: imageLib.imageSizeCache(metaData.coverImage.url),
|
|
authorImage: imageLib.imageSizeCache(metaData.authorImage.url),
|
|
ogImage: imageLib.imageSizeCache(metaData.ogImage.url),
|
|
logo: imageLib.imageSizeCache(metaData.site.logo.url)
|
|
};
|
|
|
|
return Promise
|
|
.props(fetch)
|
|
.then(function (imageObj) {
|
|
_.forEach(imageObj, function (key, value) {
|
|
if (_.has(key, 'width') && _.has(key, 'height')) {
|
|
// We have some restrictions for publisher.logo:
|
|
// The image needs to be <=600px wide and <=60px high (ideally exactly 600px x 60px).
|
|
// Unless we have proper image-handling (see https://github.com/TryGhost/Ghost/issues/4453),
|
|
// we will fake it in some cases or not produce an imageObject at all.
|
|
if (value === 'logo') {
|
|
if (key.height <= 60 && key.width <= 600) {
|
|
_.assign(metaData.site[value], {
|
|
dimensions: {
|
|
width: key.width,
|
|
height: key.height
|
|
}
|
|
});
|
|
} else if (key.width === key.height) {
|
|
// CASE: the logo is too large, but it is a square. We fake it...
|
|
_.assign(metaData.site[value], {
|
|
dimensions: {
|
|
width: 60,
|
|
height: 60
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
_.assign(metaData[value], {
|
|
dimensions: {
|
|
width: key.width,
|
|
height: key.height
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
return metaData;
|
|
});
|
|
}
|
|
|
|
module.exports = getImageDimensions;
|