mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 14:43:08 +03:00
🎨 Blog icon improvements (#8260)
refs #7688 - blog icon error message - change default favicon to 60px
This commit is contained in:
parent
06fc5f4508
commit
d9d182f7ba
@ -61,7 +61,7 @@ module.exports = function blogIcon() {
|
||||
|
||||
// CASE: file should not be larger than 100kb
|
||||
if (!validIconSize(req.file.size)) {
|
||||
return next(new errors.RequestEntityTooLargeError({message: i18n.t('errors.api.icons.fileSizeTooLarge', {extensions: iconExtensions})}));
|
||||
return next(new errors.ValidationError({message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})}));
|
||||
}
|
||||
|
||||
return getIconDimensions(req.file).then(function (dimensions) {
|
||||
@ -70,18 +70,18 @@ module.exports = function blogIcon() {
|
||||
|
||||
// CASE: file needs to be a square
|
||||
if (req.file.dimensions.width !== req.file.dimensions.height) {
|
||||
return next(new errors.ValidationError({message: i18n.t('errors.api.icons.iconNotSquare', {extensions: iconExtensions})}));
|
||||
return next(new errors.ValidationError({message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})}));
|
||||
}
|
||||
|
||||
// CASE: icon needs to be bigger than 32px
|
||||
// .ico files can contain multiple sizes, we need at least a minimum of 32px (16px is ok, as long as 32px are present as well)
|
||||
if (req.file.dimensions.width < 32) {
|
||||
return next(new errors.ValidationError({message: i18n.t('errors.api.icons.fileTooSmall', {extensions: iconExtensions})}));
|
||||
// CASE: icon needs to be bigger than 60px
|
||||
// .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 (req.file.dimensions.width <= 60) {
|
||||
return next(new errors.ValidationError({message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})}));
|
||||
}
|
||||
|
||||
// CASE: icon needs to be smaller than 1000px
|
||||
if (req.file.dimensions.width > 1000) {
|
||||
return next(new errors.ValidationError({message: i18n.t('errors.api.icons.fileTooLarge', {extensions: iconExtensions})}));
|
||||
return next(new errors.ValidationError({message: i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})}));
|
||||
}
|
||||
|
||||
next();
|
||||
|
BIN
core/server/public/favicon.ico
Normal file → Executable file
BIN
core/server/public/favicon.ico
Normal file → Executable file
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 34 KiB |
@ -371,11 +371,7 @@
|
||||
},
|
||||
"icons": {
|
||||
"missingFile": "Please select an icon.",
|
||||
"fileSizeTooLarge": "Please select an icon file smaller than 100kb.",
|
||||
"iconNotSquare": "The icon needs to be a square.",
|
||||
"fileTooLarge": "Please select an icon file smaller than 1000px.",
|
||||
"fileTooSmall": "Please select an icon file larger than 32px.",
|
||||
"invalidFile": "Please select a valid icon file.",
|
||||
"invalidFile": "Blog icon must be a square .ico or .png file between 60px – 1,000px, under 100kb.",
|
||||
"couldNotGetSize": "Couldn/'t get icon dimensions"
|
||||
},
|
||||
"users": {
|
||||
|
@ -73,7 +73,7 @@ describe('Upload Icon API', function () {
|
||||
request.post(testUtils.API.getApiQuery('uploads/icon'))
|
||||
.set('Authorization', 'Bearer ' + accesstoken)
|
||||
.expect('Content-Type', /json/)
|
||||
.attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/favicon_32x_single.ico'))
|
||||
.attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/favicon_64x_single.ico'))
|
||||
.expect(200)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
@ -151,7 +151,7 @@ describe('Upload Icon API', function () {
|
||||
.set('Authorization', 'Bearer ' + accesstoken)
|
||||
.expect('Content-Type', /json/)
|
||||
.attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/favicon_size_too_large.png'))
|
||||
.expect(413)
|
||||
.expect(422)
|
||||
.end(function (err) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
|
@ -118,7 +118,7 @@ describe('Serve Favicon', function () {
|
||||
statusCode.should.eql(200);
|
||||
},
|
||||
end: function (body) {
|
||||
body.length.should.eql(15086);
|
||||
body.length.should.eql(34494);
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
BIN
core/test/utils/fixtures/images/favicon_64x_single.ico
Executable file
BIN
core/test/utils/fixtures/images/favicon_64x_single.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
core/test/utils/fixtures/images/favicon_multi_sizes.ico
Normal file → Executable file
BIN
core/test/utils/fixtures/images/favicon_multi_sizes.ico
Normal file → Executable file
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 34 KiB |
Loading…
Reference in New Issue
Block a user