Boj Slofar
Boj Slofar

Reputation: 43

resize image if image is not gif in dropzone.js

I want to add additional options if the conditions are met.

More specifically I want to resize the image using the dropzone options if it is found that the image is not a gif.

I tried using the code below but obviously it is wrong.

  accept: function(file, done) {
    var mime_type = file.type;
    if ( mime_type != 'image/gif'){
        Dropzone.options.myAwesomeDropzone = {
        resizeWidth: 650,
        resizeMimeType: 'image/jpeg',
        resizeQuality: 0.8 }
        done();
        return;
    }
    done();
  },

Upvotes: 0

Views: 1595

Answers (1)

Boj Slofar
Boj Slofar

Reputation: 43

it turns out i just had to use this.options instead of Dropzone.options.myAwesomeDropzone

see full code below

  accept: function(file, done) {
    var mime_type = file.type;
    if ( mime_type != 'image/gif'){
        this.options.resizeWidth = 650;
        this.options.resizeMimeType = 'image/jpeg';
        this.options.resizeQuality = 0.75;
        console.log(this.options);
        done();
        return;
    }
    done();
  },

Upvotes: 2

Related Questions