In Dropzone.js how to set the minimum image resolution that we can upload? Accept is not working
dropzone.js, file-upload, javascript, jquery
Solution
I have a similar need and am using this solution:
var maxImageWidth = 1000, maxImageHeight = 1000;
Dropzone.options.dropzonePhotographs = {
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 2, // MB
dictDefaultMessage: "Drag files or click here",
acceptedFiles: ".jpeg,.jpg,.png,.gif",
init: function () {
this.on("success", function(file, responseText) {
file.previewTemplate.setAttribute('id',responseText[0].id);
});
this.on("thumbnail", function(file) {
if (file.width > maxImageWidth || file.height > maxImageHeight) {
file.rejectDimensions()
}
else {
file.acceptDimensions();
}
});
},
accept: function(file, done) {
file.acceptDimensions = done;
file.rejectDimensions = function() { done("Image width or height too big."); };
}
};
You can find the original solution here: https://github.com/enyo/dropzone/issues/708
Problem
Let's say I need to restrict my users from uploading images below 3MP (Nearly 2048px wide). How can I do this in Dropzone.js? Tried to do it with 'accept' but it's not working : ``` $(function() { var mediaDropzone; mediaDropzone = new Dropzone("#media-dropzone", { paramName: "file", autoProcessQueue: false, parallelUploads: 500, maxFilesize: <%= ENV["max_image_size"] %>, acceptedFiles: '<%= ENV["accepted_files"] %>', accept: function(file, done) { if (file.width < 2048) { done("Naha, you don't."); } else { done(); } } }); ```