mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 18:46:01 +01:00
add threshold for image resizing
This commit is contained in:
@@ -71,7 +71,7 @@ function uploadAsImage(req, uploadedFile, callback) {
|
||||
uploadsController.uploadFile(req.uid, uploadedFile, next);
|
||||
},
|
||||
function (fileObj, next) {
|
||||
if (meta.config.maximumImageWidth === 0) {
|
||||
if (meta.config.resizeImageWidth === 0 || meta.config.resizeImageWidthThreshold === 0) {
|
||||
return next(null, fileObj);
|
||||
}
|
||||
|
||||
@@ -112,14 +112,14 @@ function resizeImage(fileObj, callback) {
|
||||
image.size(fileObj.path, next);
|
||||
},
|
||||
function (imageData, next) {
|
||||
if (imageData.width < meta.config.maximumImageWidth) {
|
||||
if (imageData.width < meta.config.resizeImageWidthThreshold || meta.config.resizeImageWidth > meta.config.resizeImageWidthThreshold) {
|
||||
return callback(null, fileObj);
|
||||
}
|
||||
|
||||
image.resizeImage({
|
||||
path: fileObj.path,
|
||||
target: file.appendToFileName(fileObj.path, '-resized'),
|
||||
width: meta.config.maximumImageWidth,
|
||||
width: meta.config.resizeImageWidth,
|
||||
quality: meta.config.resizeImageQuality,
|
||||
}, next);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user