我正在实现 Blueimp jQuery 文件 uploader https://github.com/blueimp/jQuery-File-Upload我想在添加第一张图片后更改 previewMaxWidth 和 previewMaxHeight。这是因为我有一张产品特色图片,然后是产品的后续 View ,每个 View 都应显示小于特色图片。
这是我的文件上传调用:
$('.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
参数,允许在 widget 初始化后更改 options。
根据您的代码:
...
}).bind('fileuploadadded', function(e, data) {
$('.imageupload').fileupload(
'option',
{
previewMaxWidth: 60,
previewMaxHeight: 60
}
);
});
有关更改选项的更多信息,请参阅官方 API页面(选项部分)。
关于javascript - 以编程方式更改 jQuery 文件上传 (blueimp) 的 previewMaxWidth/Height,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10560377/