From b3cb1666ff5c59f0747ac6f54b87a6c8b052fcaf Mon Sep 17 00:00:00 2001 From: Thomas Portelange Date: Fri, 20 Jan 2017 21:55:42 +0100 Subject: [PATCH] fix checkImageResolution it is called with 4 arguments, yet only 3 are declared. probably something went missing when adding the new setting "minResolution". --- javascript/file_attachment_field.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/javascript/file_attachment_field.js b/javascript/file_attachment_field.js index 649cf47..99a5cae 100644 --- a/javascript/file_attachment_field.js +++ b/javascript/file_attachment_field.js @@ -266,9 +266,10 @@ UploadInterface.prototype = { * A utility method for checking the resolution of a dropped file. * @param {File} file * @param {int} maxPixels The maximum resolution, in pixels + * @param {int} minPixels The minimum resolution, in pixels * @param {Function} callback */ - checkImageResolution: function (file, maxPixels, callback) { + checkImageResolution: function (file, maxPixels, minPixels, callback) { var reader = new FileReader(), image = new Image(); @@ -287,6 +288,13 @@ UploadInterface.prototype = { maxHeight = Math.round(maxWidth * ratio); callback(false, maxWidth, maxHeight); } + if (pixels < minPixels) { + var ratio = imageH / imageW, + minWidth = Math.floor(Math.sqrt(minPixels / ratio)), + minHeight = Math.round(minWidth * ratio); + callback(false, minWidth, minHeight); + + } callback(true); };