add custom fallback image, fix #195

This commit is contained in:
lesion
2022-10-28 12:01:59 +02:00
parent 7de0206272
commit 7d0a920eb9
10 changed files with 84 additions and 21 deletions

View File

@@ -22,7 +22,6 @@ const { JSDOM } = require('jsdom')
const { window } = new JSDOM('<!DOCTYPE html>')
const domPurify = DOMPurify(window)
const url = require('url')
const locales = require('../locales')
domPurify.addHook('beforeSanitizeElements', node => {
if (node.hasAttribute && node.hasAttribute('href')) {
@@ -108,10 +107,14 @@ module.exports = {
}
})
})
router.use('/noimg.svg', express.static('./static/noimg.svg'))
router.use('/fallbackimage.png', (req, res, next) => {
const fallbackImagePath = settingsController.settings.fallbackImage || './static/noimg.svg'
return express.static(fallbackImagePath)(req, res, next)
})
router.use('/logo.png', (req, res, next) => {
const logoPath = res.locals.settings.logo || './static/gancio'
const logoPath = settingsController.settings.logo || './static/gancio'
return express.static(logoPath + '.png')(req, res, next)
})