如果条件使用pluploadQueue,我如何使用

时间:2015-11-05 12:45:47

标签: jquery

我有这个代码

("#uploadContainer").pluploadQueue({
  // General settings
  runtimes : 'gears,html5,flash,silverlight,browserplus',
  url : '{$upSet.handler}',
  max_file_size : '{$upSet.maxFilesize}mb',
  chunk_size : '1mb',
  unique_names : false,
  prevent_duplicates: true,             
  // Specify what files to browse for
  filters : [
        { title : "Files", extensions : "{$upSet.allowedFileTypes}" }
    ],
  filters: {
        min_img_resolution: 8000000 // 1MP = 1 million pixels
    },
  // Flash settings
  flash_swf_url : '{$baseURL}/assets/plupload-2.1.2/js/Moxie.swf',              
  // Silverlight settings
  silverlight_xap_url : '{$baseURL}/assets/plupload-2.1.2/js/Moxie.xap'
                        }); 

我需要在第二个过滤器之前放置if条件来选择不同的最小分辨率。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

您无法进入上传者的设置。您需要在外面执行此操作:

var min_img_resolution = 8000000; // default

if (whatever) {
    // change default if condition is met
    min_img_resolution = 4000000;
}

("#uploadContainer").pluploadQueue({
    runtimes : 'gears,html5,flash,silverlight,browserplus',
    url : '{$upSet.handler}',
    max_file_size : '{$upSet.maxFilesize}mb',
    chunk_size : '1mb',
    unique_names : false,
    prevent_duplicates: true,             
    filters : [
        { title : "Files", extensions : "{$upSet.allowedFileTypes}" }
    ],
    filters: {
        min_img_resolution: min_img_resolution // add variable here
    },
    flash_swf_url : '{$baseURL}/assets/plupload-2.1.2/js/Moxie.swf',              
    silverlight_xap_url : '{$baseURL}/assets/plupload-2.1.2/js/Moxie.xap'
});