mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-19 19:11:05 +01:00
fix: thumbs, send type for resize
This commit is contained in:
@@ -59,8 +59,12 @@ define('topicThumbs', [
|
|||||||
className: 'btn-success',
|
className: 'btn-success',
|
||||||
callback: () => {
|
callback: () => {
|
||||||
Thumbs.upload().then((thumbUrl) => {
|
Thumbs.upload().then((thumbUrl) => {
|
||||||
|
const newUrl = thumbUrl
|
||||||
|
.replace(new RegExp(`^${config.relative_path}`), '')
|
||||||
|
.replace(new RegExp(`^${config.upload_url}`), '');
|
||||||
|
|
||||||
postData.thumbs.push(
|
postData.thumbs.push(
|
||||||
thumbUrl.replace(new RegExp(`^${config.upload_url}`), '')
|
newUrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
Thumbs.modal.open({ ...payload, modal });
|
Thumbs.modal.open({ ...payload, modal });
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ async function uploadAsImage(req, uploadedFile) {
|
|||||||
return fileObj;
|
return fileObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileObj = await resizeImage(fileObj);
|
fileObj = await resizeImage({ ...fileObj, type: uploadedFile.type });
|
||||||
return { url: fileObj.url };
|
return { url: fileObj.url };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +107,7 @@ async function resizeImage(fileObj) {
|
|||||||
|
|
||||||
await image.resizeImage({
|
await image.resizeImage({
|
||||||
path: fileObj.path,
|
path: fileObj.path,
|
||||||
|
type: fileObj.type,
|
||||||
target: meta.config.resizeImageKeepOriginal ?
|
target: meta.config.resizeImageKeepOriginal ?
|
||||||
file.appendToFileName(fileObj.path, '-resized') :
|
file.appendToFileName(fileObj.path, '-resized') :
|
||||||
fileObj.path,
|
fileObj.path,
|
||||||
@@ -137,6 +138,7 @@ uploadsController.uploadThumb = async function (req, res) {
|
|||||||
if (dimensions.width > parseInt(meta.config.topicThumbSize, 10)) {
|
if (dimensions.width > parseInt(meta.config.topicThumbSize, 10)) {
|
||||||
await image.resizeImage({
|
await image.resizeImage({
|
||||||
path: uploadedFile.path,
|
path: uploadedFile.path,
|
||||||
|
type: uploadedFile.type,
|
||||||
width: meta.config.topicThumbSize,
|
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({
|
await image.resizeImage({
|
||||||
path: tempPath,
|
path: tempPath,
|
||||||
|
type: type,
|
||||||
width: 358,
|
width: 358,
|
||||||
});
|
});
|
||||||
const thumbUploadData = await image.uploadImage(`groupCoverThumb-${data.groupName}${path.extname(tempPath)}`, 'files', {
|
const thumbUploadData = await image.uploadImage(`groupCoverThumb-${data.groupName}${path.extname(tempPath)}`, 'files', {
|
||||||
|
|||||||
Reference in New Issue
Block a user