Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback on Image is completely uploaded #48

Open
ghost opened this issue May 18, 2016 · 2 comments
Open

callback on Image is completely uploaded #48

ghost opened this issue May 18, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented May 18, 2016

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.

@unclecheese
Copy link
Owner

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

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

@ghost
Copy link
Author

ghost commented May 24, 2016

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant