mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-04 03:21:18 +01:00
added filter:image.size
fix uploading of gifs if imagemagick plugin is installed but no image upload plugins are present.
This commit is contained in:
@@ -83,7 +83,7 @@ function resizeImage(fileObj, callback) {
|
||||
function(next) {
|
||||
fullPath = path.join(nconf.get('base_dir'), nconf.get('upload_path'), '..', fileObj.url);
|
||||
|
||||
image.load(fullPath, next);
|
||||
image.size(fullPath, next);
|
||||
},
|
||||
function (imageData, next) {
|
||||
if (imageData.width < parseInt(meta.config.maximumImageWidth, 10) || 760) {
|
||||
|
||||
18
src/image.js
18
src/image.js
@@ -94,11 +94,19 @@ image.normalise = function(path, extension, callback) {
|
||||
}
|
||||
};
|
||||
|
||||
image.load = function(path, callback) {
|
||||
new Jimp(path, function(err, data) {
|
||||
callback(err, data ? data.bitmap : null);
|
||||
});
|
||||
};
|
||||
image.size = function(path, callback) {
|
||||
if (plugins.hasListeners('filter:image.size')) {
|
||||
plugins.fireHook('filter:image.size', {
|
||||
path: path,
|
||||
}, function(err, image) {
|
||||
callback(err, image);
|
||||
});
|
||||
} else {
|
||||
new Jimp(path, function(err, data) {
|
||||
callback(err, data ? data.bitmap : null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
image.convertImageToBase64 = function(path, callback) {
|
||||
fs.readFile(path, function(err, data) {
|
||||
|
||||
Reference in New Issue
Block a user