Change previewMaxWidth/Height of jQuery File Upload (blueimp) programmatically

blueimp, file-upload, javascript, jquery

Solution

There is present `option` param that allows to change options after widget is initialized.

According to your code:

...

}).bind('fileuploadadded', function(e, data) {
    $('.imageupload').fileupload(
        'option',
        {
            previewMaxWidth: 60,
            previewMaxHeight: 60
        }
    );
});

More info about changing options see at official API page (section Options).

Problem

I am implementing the Blueimp jQuery File Uploader https://github.com/blueimp/jQuery-File-Upload and I'm wanting to change the previewMaxWidth and previewMaxHeight after the first image is added. This is because I have a product feature image and then subsequent views of the product, each of which should display smaller than the feature image. Here is my file upload call: ``` $('.imageupload').fileupload({ autoUpload : true, acceptFileTypes : /(\.|\/)(gif|jpe?g|png)$/i, previewMaxWidth : 198, previewMaxHeight : 800, uploadTemplateId : 'product-add-image-upload', downloadTemplateId : 'product-add-image-download' }).bind('fileuploadadded', function(e, data) { // change preview width/height to 60px/60px after first image loaded // not sure what to put here }); ```

Original source