Skip to content

Node.js based forum software built for the modern web

fix: thumbs, send type for resize

Barış Soner Uşaklı30893a1a4e78
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', {