Skip to content. | Skip to navigation

Four Digits | Willemsplein 44, 6811 KD Arnhem, The Netherlands | info@fourdigits.nl
 
Rob Gietema is one of the CEOs of Four Digits and a Zope developer for eight years. Rob was responsible for creating the front-end including the WYSIWYG editor for Coherence 2 (a CMS based on Zope). At the moment Rob is a Plone developer and maintainer of the TinyMCE Editor Plone product and the Round About Plone product. He is also currently working on the new UI for Plone (Deco).
 

Drag and Drop Image Uploading using Deco

by Rob Gietema Nov 11, 2009

In the new beta versions of Firefox 3.6 drag and drop support for uploading files is added, see what Deco can do with this functionality.

After Alexander Limi showed me some demo's of the drag and drop upload functionality added in the new beta versions of Firefox 3.6 I just had to try to add it to the Deco UI. The demo's used a fixed area where images can be dropped. In Deco you want to specify exactly where you want the images to be and not an area. To determine where to drop images Deco uses the mousemove event, but this event is not available when the window doesn't have focus (like with dragging images into a browser) so some code needed to be rewritten to use the dragover event.

Another issue was the fact the demo's use the sendAsBinary method of the XMLHttpRequest object. This method only sends the binary data itself and adding other fields like filename is not possible. I fixed this issue by creating a form request in javascript so I can add multiple fields like filename etc. All the sourcecode can be found in the Plone SVN.

 

 

This demo shows a Finder window on the left with some pictures taken at the Plone Conference 2009 and the Deco UI on the right with some example text. First a single image is dragged into the browser. The image is put on the dropped location and a black mask and loading icon is added to the image. The image is now being uploaded to the server and once ready the server returns the url and some more properties in a json structure. The correct source url is then applied to the image object.

Multiple files is also supported. Each image will be uploaded to Plone and becomes a sepparate tile. After the images are uploaded the images can be rearanged using the standard drag and drop functionality of Deco.

 
Martin Aspeli

Awesome

Posted by Martin Aspeli at Nov 11, 2009 03:08 PM
This is fantastic! :-)

What are the odds of it working in Safari/Opera/IE one day?

Martin
 
Rob Gietema

Awesome

Posted by Rob Gietema at Nov 11, 2009 03:44 PM
It will be proposed as a W3C standard by Mozilla (http://dev.w3.org/2006/webapi/FileAPI/), so hopefully the other browsers will implement this also really soon (or build the same functionality using a different method ;))
 
Duncan Booth

Awesome

Posted by Duncan Booth at Nov 11, 2009 07:28 PM
You could implement support for IE quite easily, at least for those IE users willing to install Google Gears.
See http://www.appelsiini.net/2[…]le-upload-with-google-gears for a PHP example.
 
Denys Mishunov

Just wonderful

Posted by Denys Mishunov at Nov 11, 2009 03:24 PM
Looks just awesome. Well done, Rob!
 
Tom Lazar

Future's so bright...

Posted by Tom Lazar at Nov 11, 2009 05:30 PM
... I gotta wear shades :)

this is really awesome work, rob! plone's UI is truly in good hands, thanks for all your work so far and keep it up!
 
David Glick

Image resizing

Posted by David Glick at Nov 11, 2009 05:36 PM
Very cool. Now even better would be if it integrated with the Image Editor add-on and could resize the images before uploading (can you tell we're tired of training people to pre-process their images?) :)
 
Matt Hamilton

Great Work

Posted by Matt Hamilton at Nov 11, 2009 06:13 PM
That really is truely awesome :) some great work there.

-Matt
 
Simone Deponti

Awesome

Posted by Simone Deponti at Nov 11, 2009 06:51 PM
This is awesome on many levels. I think that the UI side of the awesome part does not need comments but just eyes.
The other awesome part is that the code that makes all has been kept very simple (I mean, I understood it!) which is just great, because it means we'll be able to build on this.

So double kudos ;)
 
Erik Rose

Wow!

Posted by Erik Rose at Nov 11, 2009 07:28 PM
Holy crap! *Want!*
 
Denys Mishunov

Resizing of the images

Posted by Denys Mishunov at Nov 11, 2009 07:31 PM
Hi again Rob :) I wonder when you move images around how are they resized? width and height attributes in HTML? Or something magical happens for re-sizing there?
 
Rob Gietema

Resizing of the images

Posted by Rob Gietema at Nov 12, 2009 12:17 PM
Hi Denys, the images have a max-width: 100% style attribute so if the image is bigger then the column it will get downsized automatically. I'm not doing any magic (yet) to image scaling but it would be easy to set the images to one of the default available image scales.
 
Pedro

Absurdly, incredibly, awesomely...

Posted by Pedro at Nov 12, 2009 12:22 AM
I am so looking forward to the future of websites. On the other hand, it's gonna make me (as an old-style plain HTML/CSS/JS writer) obsolete real quick. :-) Yay for continued education!
 
Made by Four Digits based on Plone.
Made by Four Digits based on Plone.