Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,703 Points

Automated Image Gallery

Could anyone tell me a way I might accomplish this?

As of right now, every few weeks I have to upload new images into each seperate folder for my website. Then go to each individual page and change to code to match each individual file so my new gallery will show up. Each gallery is in a dated subfolder, so it is seperated from the previous "outdated" gallery.

I need a way to upload my gallery into its designated folder, then have the website code "scan" that folder for new uploaded images and list them on the designated page in a gallery style layout. With the least possible work from the users-side except for uploading the images they want into the proper folder.

Im not sure if that all came out as I typed it, but let me put it this way. I need to make gallery uploading easier for someone who is not very computer literate and does not know how to read or write code.

What would be the best route? PHP?

5 Answers

I googled 'php image gallery from folder' and http://www.ubergallery.net/ came up first. I've never used it nor have I heard of it. They have a demo.

No problem. Hope it works for you.

Sounds like eventually moving to a CMS would be your best move.

Chris Howell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Howell
Python Web Development Techdegree Graduate 49,703 Points

Ok so, I am not going to post the code I am going to use on here. I got the PHP gallery code from: ( i have not fully tested it on my site just yet. But from the example it appears to do what I need it to do.)

http://davidwalsh.name/generate-photo-gallery

  • I used a slider plugin on my site, it slides through multiple images on the main page.
  • The images for the slider are in its own folder, so using David Walsh's photo gallery code will work.
  • The slider has the little navigation "dots" or sprite images underneath picture to move back and forth between each image as the user wishes. Its going to display 8 different images from that folder.

Now I am trying to incorporate that code and build some code around it to do the following.

  • In the image folder for the slider, the code I need to generate will randomly select each image from a folder containing ANY number of images, but will only display 8 images that were randomly selected and put them into the slider each time the page is loaded. So everytime someone loads up the page, a new set of images are loaded into the "8 slots". It is okay if the page selects the same picture as on previous load, just not the same picture being display twice in the same slide sequence.

Anyone have an idea of least painless way to wrap my slider and php gallery code into some kind of auto-random generator to select an image?