2016-09-28 29 views
0

它的疯狂,但我无法谷歌。如何在blueimp jquery fileupload中设置缩略图大小?

我的电话:

$('.fileupload').fileupload({ 
    dataType: 'json', 
    done: function(e, data) { 
     $.each(data.result.files, function(index, file) { 
      // do something with file and index 
     }); 
    } 
}); 

应该有地方设置缩略图大小的选项,对不对?

Thx提前

回答

1

你说的是表单显示还是上传的img宽度?

要更改上传IMG的宽度/高度是非常简单的: 你会找到最选项:

./server/php/UploadHandler.php

那里你可以改变上传IMG 的上线146

 'thumbnail' => array(
      // Uncomment the following to use a defined directory for the thumbnails 
      // instead of a subdirectory based on the version identifier. 
      // Make sure that this directory doesn't allow execution of files if you 
      // don't pose any restrictions on the type of uploaded files, e.g. by 
      // copying the .htaccess file from the files directory for Apache: 
      //'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/thumb/', 
      //'upload_url' => $this->get_full_url().'/thumb/', 
      // Uncomment the following to force the max 
      // dimensions and e.g. create square thumbnails: 
      //'crop' => true, 
      'max_width' => 205, 
      'max_height' => 155 
     ) 
1

大小的文件重定向到自己uplo ader服务器端脚本:

$('#fileupload').fileupload({ 
     url: 'my_uploader.php', 
     dataType: 'json', 
     ... 
}); 

设置UploadHandler对象的选项。传入图像的所有调整大小的版本(甚至更多)都可以在那里配置。

my_uploader.php:

<?php 
include "lib/jQuery-File-Upload/server/php/UploadHandler.php"; 

$options = array(
    'upload_dir'=>'photo/', 
    'upload_url'=>'photo/', 

    'image_versions' => array(
       '' => array(), // original 

       'medium' => array(
        'max_width' => 800, 
        'max_height' => 800 
       ), 
       'thumbnail' => array(
        'crop' => true, 
        'max_width' => 300, 
        'max_height' => 300 
       ) 
      ) 
    ); 
$upload_handler = new UploadHandler($options); 
?> 
+0

那么,它更容易只是设置它们UploadHandler.php,喜欢接受的答案建议。 – cari

+0

我很不喜欢在“库文件”中进行更改。在更新或重新使用代码时,您遇到了麻烦。好的 - 接受的答案完成了这项工作。这在我看来更加干净。 –

+0

是的,我也喜欢这种方法,但这个库不是通过作曲家/ etc安装的,它甚至说“编辑我”本身。我记得几年前做过同样的编辑,并且经历了同样的思考过程。但最终这是没有文件,将被更新多年。 ty虽然你的想法,+1 – cari

相关问题