Skip to content

Commit

Permalink
Merge pull request #67 from lekoala/patch-1
Browse files Browse the repository at this point in the history
fix checkImageResolution
  • Loading branch information
Aaron Carlino authored Jan 20, 2017
2 parents 6eb36c0 + b3cb166 commit d94be1e
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 d94be1e

Please sign in to comment.