0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Fixed url for settings images saved in the db

closes #10590

- All images stored in the db should be relative urls and should only be served as absolute
This commit is contained in:
Nazar Gargol 2019-03-11 11:59:06 +08:00
parent d2b1e0d4b7
commit 9a831d1306
2 changed files with 14 additions and 0 deletions

View file

@ -1,4 +1,5 @@
const _ = require('lodash');
const url = require('./utils/url');
module.exports = {
read(apiConfig, frame) {
@ -36,6 +37,10 @@ module.exports = {
if (setting.key === 'codeinjection_foot') {
setting.key = 'ghost_foot';
}
if (['cover_image', 'icon', 'logo'].includes(setting.key)) {
setting = url.forSetting(setting);
}
});
}
};

View file

@ -84,6 +84,15 @@ const forTag = (attrs) => {
return attrs;
};
const forSetting = (attrs) => {
if (attrs.value) {
attrs.value = handleImageUrl(attrs.value);
}
return attrs;
};
module.exports.forPost = forPost;
module.exports.forUser = forUser;
module.exports.forTag = forTag;
module.exports.forSetting = forSetting;