I found this thread when creating and loading the client side of sketches. The tread shows how to load the first image and then execute it by resizing it and reloading it. I was wondering if there is an easy way to add one more step so that the final result creates both the original, medium size and small picture.
A better solution is to trigger QueueChanged in the FileUploaded handler, and then call refresh. This will initiate the upload again for the same file and you can set a property that you read in the BeforeUpload handler to adjust the file size.
Warning # 1: you must load the thumbnail after the full-sized image, otherwise the full-sized image may have some buffer problems and may be cropped.
Warning # 2: This will only work if the bind call for FileUploaded happens after uploader.init (), otherwise the native uploader handler for FileUploaded will overwrite file.status to DONE after your handler.
below is the original response from this thread Thumbnail Plupload
uploader.bind('BeforeUpload', function(up, file) {
if('thumb' in file)
up.settings.resize = {width : 150, height : 150, quality : 100};
else
up.settings.resize = {width : 1600, height : 1600, 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();
}
}
source
share