fix: thumbs, send type for resize

This commit is contained in:
Barış Soner Uşaklı
2026-03-01 20:13:47 -05:00
parent 06bf2abfc4
commit 30893a1a4e
3 changed files with 14 additions and 3 deletions

View File

@@ -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 });

View File

@@ -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,
};
});
};

View File

@@ -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', {