以编程方式更改 jQuery File Upload (blueimp) 的预览最大宽度/高度

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

本文关键字:高度 方式更 编程 jQuery File blueimp Upload      更新时间:2023-09-26

我正在实现Blueimp jQuery文件上传器 https://github.com/blueimp/jQuery-File-Upload,我想在添加第一张图像后更改预览MaxWidthpreviewMaxHeight。这是因为我有一个产品功能图像,然后是产品的后续视图,每个视图的显示都应小于功能图像。

这是我的文件上传电话:

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

存在option参数,允许在初始化小部件后更改选项

根据您的代码:

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

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