From 8f938eba1959024b50fa01391b0fa6b694742471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 11 Dec 2020 22:50:42 -0500 Subject: [PATCH] fix: #9074, fix svg uploads --- src/controllers/uploads.js | 5 +++-- src/image.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controllers/uploads.js b/src/controllers/uploads.js index 266c623548..bbaeb5ab31 100644 --- a/src/controllers/uploads.js +++ b/src/controllers/uploads.js @@ -69,8 +69,9 @@ async function uploadAsImage(req, uploadedFile) { await image.isFileTypeAllowed(uploadedFile.path); let fileObj = await uploadsController.uploadFile(req.uid, uploadedFile); - - if (meta.config.resizeImageWidth === 0 || meta.config.resizeImageWidthThreshold === 0) { + // sharp can't save svgs skip resize for them + const isSVG = uploadedFile.type === 'image/svg+xml'; + if (isSVG || meta.config.resizeImageWidth === 0 || meta.config.resizeImageWidthThreshold === 0) { return fileObj; } diff --git a/src/image.js b/src/image.js index ec73a0bc08..bafae61f83 100644 --- a/src/image.js +++ b/src/image.js @@ -86,7 +86,7 @@ image.size = async function (path) { }; image.stripEXIF = async function (path) { - if (!meta.config.stripEXIFData || path.endsWith('.gif')) { + if (!meta.config.stripEXIFData || path.endsWith('.gif') || path.endsWith('.svg')) { return; } try {