mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
Replaced i18n.t w/ tpl in images.js for canary
refs: TryGhost#13380 - The i18n package is deprecated. It is being replaced with the tpl package. - Important Note: invalidFile error message does not have fields for variables, but it is being passed variables.
This commit is contained in:
parent
4b6780f190
commit
71bf5e5f19
@ -1,9 +1,14 @@
|
||||
const jsonSchema = require('../utils/json-schema');
|
||||
const config = require('../../../../../../shared/config');
|
||||
const i18n = require('../../../../../../shared/i18n');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const errors = require('@tryghost/errors');
|
||||
const {imageSize, blogIcon} = require('../../../../../lib/image');
|
||||
|
||||
const messages = {
|
||||
isNotSquare: 'Please select a valid image file with square dimensions.',
|
||||
invalidFile: 'Icon must be a square .ico or .png file between 60px – 1,000px, under 100kb.'
|
||||
};
|
||||
|
||||
const profileImage = (frame) => {
|
||||
return imageSize.getImageSizeFromPath(frame.file.path).then((response) => {
|
||||
// save the image dimensions in new property for file
|
||||
@ -12,7 +17,7 @@ const profileImage = (frame) => {
|
||||
// CASE: file needs to be a square
|
||||
if (frame.file.dimensions.width !== frame.file.dimensions.height) {
|
||||
return Promise.reject(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.images.isNotSquare')
|
||||
message: tpl(messages.isNotSquare)
|
||||
}));
|
||||
}
|
||||
});
|
||||
@ -28,7 +33,7 @@ const icon = (frame) => {
|
||||
// CASE: file should not be larger than 100kb
|
||||
if (!validIconFileSize(frame.file.size)) {
|
||||
return Promise.reject(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
|
||||
message: tpl(messages.invalidFile, {extensions: iconExtensions})
|
||||
}));
|
||||
}
|
||||
|
||||
@ -39,7 +44,7 @@ const icon = (frame) => {
|
||||
// CASE: file needs to be a square
|
||||
if (frame.file.dimensions.width !== frame.file.dimensions.height) {
|
||||
return Promise.reject(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
|
||||
message: tpl(messages.invalidFile, {extensions: iconExtensions})
|
||||
}));
|
||||
}
|
||||
|
||||
@ -47,14 +52,14 @@ const icon = (frame) => {
|
||||
// .ico files can contain multiple sizes, we need at least a minimum of 60px (16px is ok, as long as 60px are present as well)
|
||||
if (frame.file.dimensions.width < 60) {
|
||||
return Promise.reject(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
|
||||
message: tpl(messages.invalidFile, {extensions: iconExtensions})
|
||||
}));
|
||||
}
|
||||
|
||||
// CASE: icon needs to be smaller than or equal to 1000px
|
||||
if (frame.file.dimensions.width > 1000) {
|
||||
return Promise.reject(new errors.ValidationError({
|
||||
message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
|
||||
message: tpl(messages.invalidFile, {extensions: iconExtensions})
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user