1 (edited by Markus 2014-03-07 15:31:10)

Topic: How to generate Thumbs during the upload queue?

Hi all,

I am completely addicted to this plugin, really great!
I am trying to create a folder where I can store the thumbs of the uploaded images. I have searched through the forum and I found something, but I have problem to use in my code.

I am able to create the thumbs folder, but I do not know how to create the thumbs and store them in this folder with PLUpload.

This is my upload.php

$selected = $_GET['category'];

$ds          = '/';  
$storeFolder = '../../upload/galleries/albums';
 
$tempFile = $_FILES['file']['tmp_name']; 
$fileName = $_FILES['file']['name'];

$targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds . $selected . $ds;
$targetFile =  $targetPath . $fileName;

$sql_run = "INSERT INTO images (imgname, gallery, imagespot) VALUES ( '$fileName', '$selected', '$fileName' )";
    
if (!mysqli_query($dblink, $sql_run)) {
    $error = 'Sorry we are experiencing some difficulties:<br> ' . mysqli_error($dblink);
    echo $error;
    exit();
}

move_uploaded_file($tempFile, $targetFile);

And this is my galleryUp.php, where I use PLUpload:

// Initialize the widget when the DOM is ready
$(function() {
    // Setup html5 version
    $("#uploader").pluploadQueue({
        // General settings
        runtimes : 'html5,flash,silverlight,html4',
        url : "upload.php?category=<?php echo $selected; ?>",
         
        chunk_size : '1mb',
        rename : true,
        dragdrop: true,
         
        filters : {
            // Maximum file size
            max_file_size : '20mb',
            // Specify what files to browse for
            mime_types: [
                {title : "Image files", extensions : "jpg,gif,png,bmp"},
            ]
        },
 
        // Resize images on clientside if we can
        resize: {
            width : 800,
            height : 600,
            quality : 100,
            crop: false // crop to exact dimensions
        },
 
 
        // Flash settings
        flash_swf_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/flash/Moxie.cdn.swf',
 
        // Silverlight settings
        silverlight_xap_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/silverlight/Moxie.cdn.xap'
    });
});

I found posts where people uses the following code to create thumbs, but I cannot figure out how to use it with my code. Any concrete help?

$("#uploader").bind('BeforeUpload', function(up, file) {
    if('thumb' in file){

        //thumb
        up.settings.url = 'upload/upload.php?diretorio=thumbs',
        up.settings.resize = {width : 100, height : 75, quality : 60};

        // medium size
        up.settings.url = 'upload/upload.php?diretorio=medium',
        up.settings.resize = {width : 200, height : 150, quality : 60}; 

    }else{
        up.settings.url = 'upload/upload.php?diretorio=full-size',
        up.settings.resize = {quality : 100};
    }    
        $("#uploader").bind('FileUploaded', function(up, file) {
            if(!('thumb' in file)) {
                file.thumb = true;
                file.loaded = 0;
                file.percent = 0;
                file.status = plupload.QUEUED;
                up.trigger("QueueChanged");
                up.refresh();
            }
    });            
});

Sorry for the long post!

Re: How to generate Thumbs during the upload queue?

You might be surprised, but I wouldn't recommend doing this. If you have to upload more than one thumb, you better upload the largest possible and do a multiple downsizing on server. It might be faster, more reliable and you will get better quality if you enable some resampling over there, since servers are still more competent in that part.

If you want to see your issue fixed, do not report it here, do it on - GitHub.

Re: How to generate Thumbs during the upload queue?

Hi davit, thank you for the hint. I will do that for sure.

This other question is not related to the thread, but I wrote to Moxiecode about the Commercial License, but after 2 weeks I have not received an answer. Do you know to whom I can write an email to ask again my question?

Re: How to generate Thumbs during the upload queue?

Markus, send me the email directly.

joakim at moxiecode dot com

Re: How to generate Thumbs during the upload queue?

Thank you. I wrote you an email some seconds ago. Best