CMS Made Simple Forums

How to let Frontend Users upload images to Gallery
Page 1 of 1

Author:  Jos [ Wed Apr 13, 2011 4:18 pm ]
Post subject:  How to let Frontend Users upload images to Gallery

A frequently requested feature for Gallery is to give frontend users the ability to upload images to Gallery.

I demonstrated how this can be done with the Uploads module at the Geekmoot 2010 and also at the 4th Dutch CMS Made Simple Workshop.

So if you want to give Frontend users a form where they can select an image from their computer and enter their own title and comment, this is how to do that in 5 easy steps:

1) install the Uploads module (depends on CGExtensions)

2) Go to the Uploads admin area and create a new category
- Category Name: Gallery
- Description: Upload to Gallery
- Server Path: images/Gallery

3) create a new content page for the upload-form with this code in the content field:
{cms_module module='Uploads' category='Gallery' mode='upload'}

4) Create a new User Defined Tag (UDT)
- Name: UploadToGallery
- Code:
$addfile = Gallery_utils::AddFileToDB($params['name'], '', Date('Y-m-d H:i:s'), 1, $params['summary'], $params['description']);

5) Go to Extensions -> Event Manager, Set Filter By Module to Uploads and select the OnUpload event. Then select the UploadToGallery UDT and add it to this event

At this point you have the Gallery Frontend Upload Form running!

You can change the looks of the uploadform in the Upload admin area (click "Modify Templates", tab Upload Templates)

- It is not possible to use the uploadfunction that is integrated in Gallery
- It is not possible to use another Gallery subdirectory, due to the (lack of) params sent out by Uploads with the OnUpload event.

Author:  polodesign [ Wed Apr 13, 2011 10:26 pm ]
Post subject:  Re: How to let Frontend Users upload images to Gallery

Wow! My timing is amazing - I just came in to plead with you to create a system for uploading through the front end and found that you had posted this just a few hours ago.

I've created a similar system for uploading through the front end, without benefit of knowing PHP or how to code a UDT, which would no doubt make the whole thing work better. But it does work. It's a bit complicated, so I hope you can follow along. I figured this out by scouring the forum and I appreciate all the suggestions that others have posted in how to get the modules talking to each other.

- I have a site where many different front end users will upload images and I need to be able to keep each user's images separate from the rest.

- I've set up individual folders within Gallery and use their FEU login usernames to name the folders. I use the AE-Gallery to display the images on the users listing.

- I'm using CompanyDirectory to store and display each person's information and use a front end editing form so that they can update their listings. The form includes a custom field called Gallery where I enter the name of their folder. I call the Gallery module using that custom field, like this:

{if $entry->customfieldsbyname.Gallery ne ''}
<h3>Image Gallery</h3>
{Gallery dir=$entry->customfieldsbyname.Gallery}

- In Uploads, I have set up a category for each user and used the value from the companyid field from the CompanyDirectory module as the category name. The server path then directs the images into the Gallery folder set up for the corresponding user, i.e. images/Gallery/username. (For consistency, I would have loved to have used the username for the Uploads category name instead of the companyid but I couldn't figure out how to do that in the time I had.) The code I use in the CD template to handle the upload is :

{cms_module module="Uploads"  category="$companyid" mode="upload" nocaptcha="1"}

Here's the site:

Hopefully you're not rolling on the floor laughing by now at how primitive this system is, because it works. Really well.

...except for 3 things...

1. I have set all this up without benefit of a UDT, so it's pretty labour-intensive to add a new user. I'm intending to have a developer write a UDT to automate the process of creating new records in the various modules so that someone else can add new users without all the work it takes now.

2. Without a UDT, I can't get the info in the summary field of the Uploads module into the title file of the Gallery module. I don't want to show the image filenames and my quick and dirty solution was to remove the code that populates the alt tag in AE-Gallery, which of course means that the images don't have any alt information. Not my preferred way of doing things.

3. Regardless of the fact that the users have been asked to resize their images before uploading, they're sending 2 MB images. I was really hoping to find a way to resize the images while they are being uploaded, the way the Gallery module does so beautifully when uploading through the admin. This is why I came on here today to plead with you to create a way to do that.

Any thoughts on whether it's possible to get these images resized as they're being uploaded? I've used Jeremy Bass's SuperSizer module on another site and it works well but I haven't looked into whether it might work in this situation. However, with that module, the images are still uploaded in their huge size and then resized, and saved with a lot of extra numbers in the filenames. So the original images are still there and the filenames are confusing. I really love the way Gallery does the resizing during the upload so that the server space doesn't get filled up with huge, unused files. I've taken a quick look at Calguy's new SmartImage toolkit but as far as I can tell, it also affects only the output and I haven't yet figured out whether I can incorporate it into this system.

So - does the process of adding the file using your UploadToGallery UDT do any resizing or does it simply place the file in the Gallery folder? Is it even possible to do this kind of resizing? Does anyone else have any thoughts on how I might accomplish this? Or am I doomed to spending hours teaching people how to resize their images before uploading?

Grateful for any assistance and/or guidance,

Author:  Kippertje [ Fri May 06, 2011 2:03 pm ]
Post subject:  Re: How to let Frontend Users upload images to Gallery

Hi fellows,

I am using the upload module but i have a serious question about it.
When somebody has uploaded an image i dont get my thank you page wich i have made.

How do i get it????

Author:  mskeet [ Sat May 07, 2011 11:47 pm ]
Post subject:  Re: How to let Frontend Users upload images to Gallery

Perfect! Thank you Jos. It's what I've been looking for.

I have a question though, how can I retrieve all the images uploaded by a specific user when I'm using CG User Directory? Does anyone know how to accomplish this?

Author:  manuel [ Fri Oct 21, 2011 11:23 am ]
Post subject:  Re: How to let Frontend Users upload images to Gallery

Thx for sharing Jos!!


Author:  Ramms [ Thu Oct 11, 2012 9:46 am ]
Post subject:  Re: How to let Frontend Users upload images to Gallery



Help please ;)

Author:  Jos [ Thu Oct 11, 2012 10:03 am ]
Post subject:  Re: How to let Frontend Users upload images to Gallery


Author:  grid24 [ Tue Jul 30, 2013 1:13 pm ]
Post subject:  Re: How to let Frontend Users upload images to Gallery

I'm also having problems getting a page to show after the file has uploaded.

Although the URL is correct, it only shows the 'live' text that's on the page - none of the rest of the site template or Gallery scripts that are on the page.

If I 'refresh' the page, it asks me to re-send the form. On cancelling this, the page does eventually load correctly.

Probably something simple I'm doing wrong (as ever!), but any help would be much appreciated.

Author:  Rolf [ Sun Mar 22, 2015 4:14 pm ]
Post subject:  Re: How to let Frontend Users upload images to Gallery

Related viewtopic.php?f=7&t=72572

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group