Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

});
like image 642
Josh Stuart Avatar asked Feb 20 '23 12:02

Josh Stuart


1 Answers

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).

like image 81
antyrat Avatar answered Mar 09 '23 00:03

antyrat