Skip to content

Commit

Permalink
fix checkImageResolution
Browse files Browse the repository at this point in the history
it is called with 4 arguments, yet only 3 are declared. probably something went missing when adding the new setting "minResolution".
  • Loading branch information
lekoala authored Jan 20, 2017
1 parent 6eb36c0 commit b3cb166
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion javascript/file_attachment_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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);
};
Expand Down

0 comments on commit b3cb166

Please sign in to comment.