From acc030e6da538d78c77627ba0582aa0729862faf Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 9 May 2016 22:25:51 +0300 Subject: [PATCH] added filter:image.size fix uploading of gifs if imagemagick plugin is installed but no image upload plugins are present. --- src/controllers/uploads.js | 2 +- src/image.js | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/controllers/uploads.js b/src/controllers/uploads.js index d096ecf0de39..087889d3400a 100644 --- a/src/controllers/uploads.js +++ b/src/controllers/uploads.js @@ -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) { diff --git a/src/image.js b/src/image.js index 7efe86c6ee4d..fca120d1e54c 100644 --- a/src/image.js +++ b/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) {