How to let Frontend Users upload images to Gallery

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Locked
Jos
Support Guru
Support Guru
Posts: 4017
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

How to let Frontend Users upload images to Gallery

Post by Jos »

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:

Code: Select all

{cms_module module='Uploads' category='Gallery' mode='upload'}
4) Create a new User Defined Tag (UDT)
- Name: UploadToGallery
- Code:

Code: Select all

$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)


Note:
- 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.
Last edited by Jos on Sun Mar 22, 2015 6:23 pm, edited 1 time in total.
User avatar
polodesign
Forum Members
Forum Members
Posts: 55
Joined: Sun Jan 03, 2010 1:58 am

Re: How to let Frontend Users upload images to Gallery

Post by polodesign »

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:

Code: Select all

{if $entry->customfieldsbyname.Gallery ne ''}
<h3>Image Gallery</h3>
{Gallery dir=$entry->customfieldsbyname.Gallery}
{/if}
- 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 :

Code: Select all

{cms_module module="Uploads"  category="$companyid" mode="upload" nocaptcha="1"}
Here's the site: http://www.artsquintewest.ca

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,
Penny
Kippertje
Forum Members
Forum Members
Posts: 69
Joined: Tue Jan 11, 2011 3:22 pm

Re: How to let Frontend Users upload images to Gallery

Post by Kippertje »

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????
mskeet
Forum Members
Forum Members
Posts: 22
Joined: Sat Jan 10, 2009 6:59 pm

Re: How to let Frontend Users upload images to Gallery

Post by mskeet »

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?
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: How to let Frontend Users upload images to Gallery

Post by manuel »

Thx for sharing Jos!!

Greetings,
Manuel
Jos
Support Guru
Support Guru
Posts: 4017
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: How to let Frontend Users upload images to Gallery

Post by Jos »

grid24
Forum Members
Forum Members
Posts: 15
Joined: Fri May 04, 2012 1:53 pm
Location: London

Re: How to let Frontend Users upload images to Gallery

Post by grid24 »

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.
User avatar
Rolf
Dev Team Member
Dev Team Member
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: How to let Frontend Users upload images to Gallery

Post by Rolf »

- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Locked

Return to “Tips and Tricks”