以编程方式更改previewMaxWidth/jQuery File Upload(blueimp)的高度

Jos*_*art 4 javascript jquery file-upload blueimp

我正在实现Blueimp jQuery File Uploader https://github.com/blueimp/jQuery-File-Upload,我想在添加第一个图像后更改previewMaxWidthpreviewMaxHeight.这是因为我有产品特征图像,然后是产品的后续视图,每个视图应显示小于特征图像.

这是我的文件上传调用:

$('.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

});
Run Code Online (Sandbox Code Playgroud)

ant*_*rat 8

存在optionparam,允许在窗口小部件初始化后更改选项.

根据你的代码:

...

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

有关更改选项的更多信息,请参阅官方API页面(选项部分).