UberUploadCropper Update – Upload and Crop Multiple Files
11 Dec
Posted by: trent in: Impromptu, Javascript, PHP
UberUploadCropper is a jQuery plugin with brings together Fine Uploader, jQuery Impromptu, and Jcrop to upload and crop multiple images. This utility queues up the images in Impromptu using states, and you can traverse to each uploaded image and resize each.
In the previous version there was a bug preventing multiple images from being cropped. This is now resolved! The new version brings updated libraries and introduced a few bindable events:
- uberSingleUploadComplete: function(event, responseJson) – called after each upload. responseJson is the response from the server upload script.
- uberAllUploadsComplete: function(event, imgData) – called after all uploads complete. imgData is an array of each responseJson.
- uberOnComplete: function(event, imgData, cropResponse) – called after the crop is complete and the prompt has closed. imgData is an array of responses from the upload. cropResonse is the response from the server crop script.
Also, when passing the options in you should now pass in grouped options. This way there is no overlap between plugins. Here is a quick example:
$('#UploadImages').uberuploadcropper({
// fineuploader settings within this object
fineuploader: {
request : {
endpoint: 'upload.php'
},
validation: {
allowedExtensions: ['jpg','jpeg','png','gif']
}
},
// impromptu settings within this object
impromptu: {
classes: 'myclass'
},
// jcrop settings within this object
jcrop: {
aspectRatio : 1,
allowSelect : false, //can reselect
allowResize : false, //can resize selection
setSelect : [ 0, 0, 200, 200 ] //these are the dimensions of the crop box x1,y1,x2,y2
},
// uber settings sit in the base object
folder : 'uploads/', // only used in uber, not passed to server
cropAction : 'crop.php', // server side request to crop image
onComplete : function(e,imgs,data){
console.log(imgs);
}
});
The following is a short video of it in action (This is a video from the previous version, which could only upload one at the time).
It should be noted that the examples provided are just that, examples. You will need to do some handy work customizing the styles and the server side uploads. I have commented the code to try and point you in the correct direction. The examples are in php, however it should be pretty straight forward to implement in any language. (See the Fine Uploader serverside folder)
If you want to become more familiar with jQuery Impromptu so you can create more advanced prompts like UberUploadCropper I highly recommend the ebook “Impromptu From I to U”. It covers using buttons, states, forms, asynchronous behaviors, and more.
buy PDF + Code
buy PDF Only
You can find UberUploadCopper on Github. There you can post any issues or send pull requests. Before posting issues on uploading be sure to check that your upload directories are writable, check your error logs, and examine your network requests in firebug/web console. Hope you enjoy!




20 Responses
hups
Dec 29, 2012Hello ,
great script !
i have upload one image, ok , but now when i upload another image the script stop with prozessing?
after refresh is ok
any ideas?
jack
Jan 06, 2013When doing multiple uploads one at a time it freezes after the first one.
Any help would be great?
trent
Jan 11, 2013Hey Justin, Thanks for looking in to this as I have not had a chance. Something to try:
around line 135 in jquery-uberuploadcropper.js:
.on('complete', function(event, id, fileName, responseJson){
imgdata.push(responseJson);
try clearing imgdata just before the push:
.on('complete', function(event, id, fileName, responseJson){
imgdata = [];
imgdata.push(responseJson);
Not sure if that will work, but from what you describe that should clear out previous uploads. Are any errors thrown?
Edit:
I think that will clear it out before every upload, so it would only work for single mode, not multi upload mode. Try clearing the imgdata in a submit event. So right before the on(‘complete’… add a submit:
.on('submit', function(id, filename){
imgdata = [];
})
.on('complete', function(event, id, fileName, responseJson){
imgdata.push(responseJson);
// ....... the rest ...
May have to play with which event to use, I think submit may do the trick though:
https://github.com/valums/file-uploader/blob/master/readme.md#callbacks-fineuploader–fineuploaderbasic
derox
Jan 16, 2013great script, exactly what i’m looking for. thank you very much. i got the same error like hups or jack. i’ll try the solution.
is it possible to add a watermark on the final image? i’ll put two radio input buttons for different watermark images on the page, so that the user can choose. another highlight are to rotate the pictures before cropping.
thanks, derox
trent
Jan 16, 2013Yes, I don’t provide the code, but inside the crop.php on the server side you can easily do the watermarking there, as well as any other conversions/resizing/etc..
derox
Jan 16, 2013thanks for your feedback. i thought so, but i don’t know how to pass the variables from the input fields to crop.php. fileuploader support the params{} function to GET it in upload.php. i found nothing about that for jcrop?
derSteffen
Jan 18, 2013Hello,
very very nice. I have a question. If I upload a image and I dont’t crop beacuase I click to the (x) for cancel the original image an the __Fullsize image doesnt delete.
But if I crope this both image will be delete.
Is there a solution that the original upload and the __Fullsize image will be delet (unlink) if I cancel.
Thank you very much!
Greetings Steffen
derSteffen
Jan 18, 2013Hello,
the freeze-effect is still existing if you upload image or images in more than one step. Both Solutions doesnt solve the problem. If you upload and crope one image or if you upload and crope in oe step multiple image and crope everything is fine, but if you upload and crope a second single image or if you want to upload multible image a second time it will we freeze. In the background I see the new (second) crope image twice and the Layer “Processing” dont fade out.
Thank you very much
Greetings Steffen
Tim Romano
Jan 23, 2013ISO 8601 3.5.2 distinguishes between combined date-time values and time-only values. The latter are not “on the calendar” and simply map to the 24-hour clock. The ISO standard makes 24:00 a valid value for time-only representations, to distinguish the start of the day (00:00) from the end of the day (24:00). I would like to see an ISOTimePicker that conformed to ISO 8601 3.5.2 when it is placed in Time-Only mode. When the hours chunk is set to 24, seconds, fractions of seconds must be 0.
trent
Jan 24, 2013Tim, I think this landed on the wrong post. However you can post issues and pull requests over on the Github project page. There you will find a larger community that may be able to help or contribute to the project sooner:
https://github.com/trentrichardson/jQuery-Timepicker-Addon
Wayne
Jan 24, 2013Hey.. very nice .. simple and easy. How-ever.. I want to upload photos of 945×490, min and max. I can’t seem to get the crop box to set at anything except a square. Even if I set the setSelect at [0, 0, 300, 100] the crop box does not open to those dimensions.
Am I missing something important?
derSteffen
Jan 25, 2013Hello Wayne,
you have to change the ratio-value, to change the dimensions.
Hello trent,
is there a solution, that the uploaded and the resize image will be delete if i click the cancel-”x”
Thank you very much.
Greetings Steffen
trent
Jan 25, 2013You may be able to try delegating an impromptu event (promptclose) from the body element (the Prompt is created in the body element). If I can remember correctly the second parameter will be undefined if “X” is clicked or programatically closed.
keith
Mar 20, 2013once an image is uploaded, the crop area keeps moving after clicking. then causes a ‘too much recursion’ error in jquery. I see the stopProp and stopDefault in the code. any ideas???
trent
Mar 25, 2013Hey Keith, Have you tried the latest on github? I believe we fixed this a week or two ago.
Jesus
Mar 30, 2013Good evening, I have a question regarding the size of a photo, I am using the code but not exactly what part I have to modify to make say a photo to a size of 250 x 150, thank you for your feedback. Right now I’m editing the index for this. Thank you very much.
trent
Apr 01, 2013You will want to update crop.php. The advanced example does a resize around line 46
keith
Apr 01, 2013Hey Trent, the issue I was having was a conflict with Bootstrap and Jcrop. Here’s the fix:
https://github.com/tapmodo/Jcrop/issues/79
just have to add (at or around line #1153 in jquery.Jcrop.js):
$(document).unbind(‘touchmove.jcrop’);
$(document).unbind(‘touchend.jcrop’);
$(document).unbind(‘mousemove.jcrop’);
$(document).unbind(‘mouseup.jcrop’);
Jason P
Jun 03, 2013Hi Trent,
Great plugin mix. Question: Would it be in the crop.php where I’d place the session variable and update the mysql database with $filePath as the location of the image? I’m trying it now and it doesn’t register.
Thanks in advance,
Jason
trent
Jun 03, 2013You can place it in the upload or crop.php. If you will be changing the filename when cropping definitely do it in crop.php. If you will be keeping the same filename you can do it in the upload.php. Check your php logs if it is not saving, there could be an error preventing the query from completing.