mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
Replaced i18n.t w/ tpl in core/server/api/v3/utils/validators/input/images.js (#13530)
refs: #13380 - The i18n package is deprecated. It is being replaced with the tpl package.
This commit is contained in:
parent
421c71d4db
commit
9fe0b3df1a
@ -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})
|
||||
}));
|
||||
}
|
||||
});
|
||||
@ -77,4 +82,4 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user