jquery file upload disable thumbnail generation

user1995781 picture user1995781 · Mar 24, 2014 · Viewed 7.6k times · Source

I am using jQuery File Upload plugin (http://blueimp.github.io/jQuery-File-Upload/) for image upload for my website. I am trying to disable UploadHandler.php from generating thumbnail image on the server. After some searching, I found this: https://github.com/blueimp/jQuery-File-Upload/issues/2223

My Code:

error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');

$options = array (
    'upload_dir' => dirname(__FILE__) . '/uploaddir/',
'image_versions' => array()
);

$upload_handler = new UploadHandler($options);

When I try to upload file, it is not generating thumbnail in to the thumbnail folder. But it generate another smaller image on the uploaddir folder with the resolution 800 x 800.

So, how to properly disable thumbnail generation in UploadHandler.php?

Thank you.

Answer

Nis picture Nis · Mar 24, 2014

The default index.php file should look like following.

error_reporting(E_ALL | E_STRICT); require('UploadHandler.php'); $upload_handler = new UploadHandler();




In your index.php file before the following function call

$upload_handler = new UploadHandler();

add the following code...

$options = array(
    // This option will disable creating thumbnail images and will not create that extra folder.
    // However, due to this, the images preview will not be displayed after upload
    'image_versions' => array()
);  

and then CHANGE the UploadHandler() function call to the pass the option as follows

$upload_handler = new UploadHandler($options);


Short Explanation

In UploadHandler.php file there are default options. One of which is 'image_versions'. This option sets all relevant options to create server side thumbnail image.

With the above explained changes we are overwriting the 'image_versions' option to be an empty array (which is same as not having this option).

This disables the server side thumbnail creation.