mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-02 18:41:19 +01:00
fix: thumbs, send type for resize
This commit is contained in:
@@ -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 });
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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', {
|
||||
|
||||
Reference in New Issue
Block a user