cari
cari

Reputation: 2300

How can i set the thumbnail size in blueimp jquery fileupload?

Its crazy, but i was not able to google that.

My call:

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

There should be an option to set thumbnail size somewhere, right?

Thx in advance

Upvotes: 1

Views: 1696

Answers (2)

cnm
cnm

Reputation: 61

Are you talking form displaying the height or width of the uploaded img?

To change width/height of uploaded img is very simple: You will find the most options in:

./server/php/UploadHandler.php

there you can change the size of uploaded img on line 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 
        )

Upvotes: 2

M.i.X
M.i.X

Reputation: 345

Redirect the files to your own uploader server side script:

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

Set the options of the UploadHandler object. All the resized versions (even more then one!) of the incoming image can be configured there.

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);
?>

Upvotes: 2

Related Questions