From 30893a1a4e7870ab11194063485fbffd3ab5cc6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 1 Mar 2026 20:13:47 -0500 Subject: [PATCH] fix: thumbs, send type for resize --- public/src/modules/topicThumbs.js | 6 +++++- src/controllers/uploads.js | 10 ++++++++-- src/groups/cover.js | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/public/src/modules/topicThumbs.js b/public/src/modules/topicThumbs.js index 340d856ded..1af367bc1f 100644 --- a/public/src/modules/topicThumbs.js +++ b/public/src/modules/topicThumbs.js @@ -59,8 +59,12 @@ define('topicThumbs', [ className: 'btn-success', callback: () => { Thumbs.upload().then((thumbUrl) => { + const newUrl = thumbUrl + .replace(new RegExp(`^${config.relative_path}`), '') + .replace(new RegExp(`^${config.upload_url}`), ''); + postData.thumbs.push( - thumbUrl.replace(new RegExp(`^${config.upload_url}`), '') + newUrl, ); Thumbs.modal.open({ ...payload, modal }); diff --git a/src/controllers/uploads.js b/src/controllers/uploads.js index c150c7144d..fc17f44b4b 100644 --- a/src/controllers/uploads.js +++ b/src/controllers/uploads.js @@ -79,7 +79,7 @@ async function uploadAsImage(req, uploadedFile) { return fileObj; } - fileObj = await resizeImage(fileObj); + fileObj = await resizeImage({ ...fileObj, type: uploadedFile.type }); return { url: fileObj.url }; } @@ -107,6 +107,7 @@ async function resizeImage(fileObj) { await image.resizeImage({ path: fileObj.path, + type: fileObj.type, target: meta.config.resizeImageKeepOriginal ? file.appendToFileName(fileObj.path, '-resized') : fileObj.path, @@ -137,6 +138,7 @@ uploadsController.uploadThumb = async function (req, res) { if (dimensions.width > parseInt(meta.config.topicThumbSize, 10)) { await image.resizeImage({ path: uploadedFile.path, + type: uploadedFile.type, width: meta.config.topicThumbSize, }); } @@ -148,7 +150,11 @@ uploadsController.uploadThumb = async function (req, res) { }); } - return await uploadsController.uploadFile(req.uid, uploadedFile); + const storedFile = await uploadsController.uploadFile(req.uid, uploadedFile); + return { + url: storedFile.url, + name: storedFile.name, + }; }); }; diff --git a/src/groups/cover.js b/src/groups/cover.js index a643126ecb..020f14314e 100644 --- a/src/groups/cover.js +++ b/src/groups/cover.js @@ -44,6 +44,7 @@ module.exports = function (Groups) { await image.resizeImage({ path: tempPath, + type: type, width: 358, }); const thumbUploadData = await image.uploadImage(`groupCoverThumb-${data.groupName}${path.extname(tempPath)}`, 'files', {