diff --git a/server/controllers/common.js b/server/controllers/common.js index ceae8650..597b278f 100644 --- a/server/controllers/common.js +++ b/server/controllers/common.js @@ -38,7 +38,6 @@ router.get('/_site/:siteId?/:resource', async (req, res, next) => { if (!site) { return res.status(404).send('Site Not Found') } - console.info(req.params) switch (req.params.resource) { case 'logo': { if (site.config.assets.logo) { @@ -76,7 +75,7 @@ router.get('/_site/:siteId?/:resource', async (req, res, next) => { /** * Asset Thumbnails / Download */ -router.get('/_thumb/:id.png', async (req, res, next) => { +router.get('/_thumb/:id.webp', async (req, res, next) => { const thumb = await WIKI.db.assets.getThumbnail({ id: req.params.id }) @@ -86,16 +85,16 @@ router.get('/_thumb/:id.png', async (req, res, next) => { switch (thumb.previewState) { case 'pending': { - res.send('PENDING') + res.redirect('/_assets/illustrations/fileman-pending.svg') break } case 'ready': { - res.set('Content-Type', 'image/png') + res.set('Content-Type', 'image/webp') res.send(thumb.preview) break } case 'failed': { - res.status(500).send('Thumbnail Preview Failed').end() + res.redirect('/_assets/illustrations/fileman-failed.svg') break } default: { diff --git a/server/graph/resolvers/asset.js b/server/graph/resolvers/asset.js index c1a585bc..22aa08b7 100644 --- a/server/graph/resolvers/asset.js +++ b/server/graph/resolvers/asset.js @@ -309,10 +309,10 @@ module.exports = { WIKI.logger.warn('Cannot generate asset thumbnail because the Sharp extension is not installed.') } else { WIKI.logger.debug(`Generating thumbnail of asset ${sanitizedFilename}...`) - const previewDestPath = path.resolve(WIKI.ROOTPATH, WIKI.config.dataPath, `uploads/${tempFileId}-thumb.png`) + const previewDestPath = path.resolve(WIKI.ROOTPATH, WIKI.config.dataPath, `uploads/${tempFileId}-thumb.webp`) // -> Resize await WIKI.extensions.ext.sharp.resize({ - format: 'png', + format: 'webp', inputStream: createReadStream(), outputPath: previewDestPath, width: 320, diff --git a/server/models/tree.js b/server/models/tree.js index de4a94dc..448d3745 100644 --- a/server/models/tree.js +++ b/server/models/tree.js @@ -176,8 +176,9 @@ module.exports = class Tree extends Model { folderPath: '', fileName: '' } - const folderPath = commonHelper.decodeTreePath(folder.folderPath ? `${folder.folderPath}.${folder.fileName}` : folder.fileName) - const fullPath = folderPath ? `${folderPath}/${fileName}` : fileName + const folderPath = folder.folderPath ? `${folder.folderPath}.${folder.fileName}` : folder.fileName + const decodedFolderPath = commonHelper.decodeTreePath(folderPath) + const fullPath = decodedFolderPath ? `${decodedFolderPath}/${fileName}` : fileName WIKI.logger.debug(`Adding asset ${fullPath} to tree...`) diff --git a/ux/public/_assets/illustrations/fileman-failed.svg b/ux/public/_assets/illustrations/fileman-failed.svg new file mode 100644 index 00000000..0dc66200 --- /dev/null +++ b/ux/public/_assets/illustrations/fileman-failed.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/ux/public/_assets/illustrations/fileman-pending.svg b/ux/public/_assets/illustrations/fileman-pending.svg new file mode 100644 index 00000000..69df0e58 --- /dev/null +++ b/ux/public/_assets/illustrations/fileman-pending.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/ux/src/components/FileManager.vue b/ux/src/components/FileManager.vue index fc374368..b51023e5 100644 --- a/ux/src/components/FileManager.vue +++ b/ux/src/components/FileManager.vue @@ -473,7 +473,7 @@ const currentFileDetails = computed(() => { break } case 'asset': { - thumbnail = `/_thumb/${item.id}.png` + thumbnail = `/_thumb/${item.id}.webp` items.push({ label: t('fileman.detailsAssetType'), value: fileTypes[item.fileExt] ? t(`fileman.${item.fileExt}FileType`) : t('fileman.unknownFileType', { type: item.fileExt.toUpperCase() })