Uploading Multiple Images (a solution)

Last modified: October 17, 2007 - 19:22

After countless searches for a method to upload multiple images (that were individual nodes) using the standard image module or even a cck field type and some thought and re-thought about a method to at least mimic the ability to upload multiple images, I think I have found a reasonable solution. It's not as great as having several upload fields...but it's good enough.

The answer - very simple: Pageroutes!

1. Download and install the pageroute module.
2. Go to admin/build/pageroute
3. Select "Add Route"
4. Type a path for your route - I called mine "image-upload"
5. For Tabs options - doesn't really matter.
6. Ignore "Nodefamily" (if you have it installed).
7. In advanced settings, set the customized redirect path to the name of whatever your route is. My route was image-upload, so that's my customized redirect path. This is done so the user will keep being redirected to the route until they choose to exit.
8. Submit.
9. Select "add page" on your new route.
10. Choose "node adding form" - then click forward.
11. Name your page - you can call it image or picture or whatever floats your boat (I prefer lowercase and note it will be in url so no spaces)
12. Select content type (image, if you are using image module or whatever CCK content type you are using for images)
13. I like to remove the forward, cancel and back text - we don't really need those buttons.
14. Be sure too check "display submit button" and do not check "preview button"
15. Submit.
16. You can add a few more pages if you like, but I don't think it should matter, since the end of route should redirect to the start.
But note the route in my case moves faster between pages (just a little bit - barely noticeable) between pages vs starting over from the beginning. For each additional page, use same settings, but of course the name can't be the same, so you can incrementally add numbers.

You can add about 3 pages - that should be enough.
That's it!! Users can now quickly upload multiple images. It's not as fast as having several upload boxes - but I think it works well.

Now, what you have essentially created is an endless loop - users will never be able to get out of it. So what I chose to do was to edit the page by adding some tabs.

I created a custom page-(my-route-name).tpl.php file and added tabs manually (look at the source of your user account page to see the code).
The first tab - would be that page, so it's hard coded into the template (with the class being active on that page).
The second tab says "view images" and it takes them to a view page that shows all images they have uploaded - this has to be it's own custom page also - so as to display the tabs, with the class being active on this page.

Lastly, I added some text explaining that they must click on "view images" (or some other link to get away from the upload image form) on the first custom tpl.php page I created.

This option is great for cases where you want to be able to handle each image individually. Another option would be simply to create a Custom CCK type, add an image field (must have cck and imagefield installed) and allow multiple values - but this way all the images are one node, so there isn't much flexibility with it.

Let me know if this helps you out.

 
 

Drupal is a registered trademark of Dries Buytaert.