最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Change previewMaxWidthHeight of jQuery File Upload (blueimp) programmatically - Stack Overflow

programmeradmin0浏览0评论

I am implementing the Blueimp jQuery File Uploader 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

});

I am implementing the Blueimp jQuery File Uploader https://github./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

});
Share Improve this question edited Nov 23, 2012 at 10:02 Dirty-flow 2,30011 gold badges30 silver badges49 bronze badges asked May 12, 2012 at 1:39 Josh StuartJosh Stuart 1,5281 gold badge13 silver badges23 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8 +50

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

发布评论

评论列表(0)

  1. 暂无评论