Skip to content

Commit

Permalink
Merge pull request #37 from nimeso/patch-2
Browse files Browse the repository at this point in the history
Add setMinResolution setting
  • Loading branch information
Aaron Carlino authored Sep 20, 2016
2 parents 58d36f5 + 9e06f5d commit 6b8debf
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions javascript/file_attachment_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,28 @@ UploadInterface.prototype = {
* @param {File} file
* @param {Function} done
*/
accept: function (file, done) {
if(this.settings.maxResolution && file.type.match(/image.*/)) {
this.checkImageResolution(file, this.settings.maxResolution, function (result, width, height) {
var msg = null;
if(!result) {
accept: function (file, done) {
if((this.settings.maxResolution || this.settings.minResolution) && file.type.match(/image.*/)) {
this.checkImageResolution(file, this.settings.maxResolution, this.settings.minResolution, function (result, errorType, width, height) {
var msg = null;
if(!result) {
if(errorType == "big"){
msg = 'Resolution is too high. Please resize to ' + width + 'x' + height + ' or smaller';
}else{
msg = 'Resolution is too small. Please resize to ' + width + 'x' + height + ' or bigger';
}
try {
done(msg);
}
// Because this check is asynchronous, the file has already been queued at this point
// and Dropzone throws an error for queuing a rejected file. Just ignore it.
catch (e) {}
});
}
else {
return done();
}
}
try {
done(msg);
}
// Because this check is asynchronous, the file has already been queued at this point
// and Dropzone throws an error for queuing a rejected file. Just ignore it.
catch (e) {}
});
}
else {
return done();
}
},

/**
Expand Down

0 comments on commit 6b8debf

Please sign in to comment.