以编程方式更改jQuery文件上传(blueimp)的previewMaxWidth / Height [英] Change previewMaxWidth/Height of jQuery File Upload (blueimp) programmatically
问题描述
我正在实施Blueimp jQuery File Uploader https://github.com/blueimp/jQuery-文件上传,我想在添加第一个图像后更改 previewMaxWidth 和 previewMaxHeight 。这是因为我有一个产品功能图像,然后产品的后续视图,其中每个应显示比特征图像小。
这是我的文件上传调用:
$('。imageupload')。fileupload({
autoUpload:true,
acceptFileTypes:/ (\。| \ /)(gif | jpe?g | png)$ / i,
previewMaxWidth:198,
previewMaxHeight:800,
uploadTemplateId:'product-add-image ('fileuploadadded',function(e,data){
//改变预览宽度/高度在第一张图片加载到
后//不知道要放在哪里
});
/ code> param,允许在widget初始化后更改 options 。
根据您的代码:
$ $ $ $
$ b $) ('.imageupload')。fileupload(
'option',
{
previewMaxWidth:60,
previewMaxHeight:60
}
);
});
有关更改选项的更多信息,请参阅官方 API 页面( Options 部分)。
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
});
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).
这篇关于以编程方式更改jQuery文件上传(blueimp)的previewMaxWidth / Height的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!