silverstripe-dropzone icon indicating copy to clipboard operation
silverstripe-dropzone copied to clipboard

callback on Image is completely uploaded

Open ghost opened this issue 9 years ago • 2 comments

Dear Uncle Cheese,

I made a silverstripe Module called cropfield. Its adding the functionallity of JCrop to dropzone for uploading (profile)pictures in frontend. In cropfield.js I am using $('#Dropzone').data('dropzoneInterface').backend.on('complete',function(){...} (I also tried success instead of complete). I need to get the size of the original uploaded Image. I do this with:

var pic_real_width = document.querySelector('#cropArea').naturalWidth;
var pic_real_height = document.querySelector('#cropArea').naturalHeight;

But to get the real Values I do have to set a timeout, because when I dont't I allways get 0. I need a callback function that triggers when the Image is completly uploaded and added to Dom so I can get the real Values for width and height and get rid of the timeout.

You can find my code here: [https://github.com/TheTigerDuck/silverstripe-cropfield]

By the Way Thanks for all your awesome work on silverstripe and excuse my bad english.

ghost avatar May 18 '16 10:05 ghost

Have you looked at this? http://www.dropzonejs.com/#event-list

Surely one of those events will give you what you need.

unclecheese avatar May 24 '16 01:05 unclecheese

No I hanen't. When I use thumbnail I can take the values of width and height from dataURL. Thanks.

$('#Dropzone').data('dropzoneInterface').backend.on('thumbnail',function(dataUrl){ var pic_real_width = dataUrl.width; var pic_real_height = dataUrl.height;

ghost avatar May 24 '16 12:05 ghost