close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Image Gallery from directory

Thread began 9/02/2009 2:54 pm by Carl | Last modified 9/03/2009 10:31 am by Carl | 1612 views | 2 replies |

Carl

Image Gallery from directory

Hi,

I want to pick out all the images in a specific folder and display them in a gallery view
e.g.
image 1 image 2 image3
image 4 image 5 image6
image 7

does anyone know how to do this?

Thanks

Carl

Sign in to reply to this post

anonymous

Hi Carl,

Sure thing... the first thing you want to do is build an array from the folder's contents.

You would use the "scandir" command, such as $imagegal = scandir('yourFolder');

Once you have the array, loop through it with something like a "for each" loop and then test to see if each file is an image. You have to do this because a lot of times, there will be hidden files in a folder for notes or other things.

You can test if it is an image simply by making an if statement with getimagesize. For example: if (getimagesize($loopIteration)

This works because if it is not an image, it won't create a value there.

So you could have inside your for each loop of the scandir array,

<?php


if (getimagesize($i)) { ?>

<div class"yourClass"><img src="/yourFolder/$i" /></div>

<?php } ?>


Let me know if you need more details... I only had a few moments to post this... I can send you an email later or post more details when I get home tonight.

Best regards,

Brian

Sign in to reply to this post

Carl

Thanks for the reply Brian

If you could, please can you write the whole code out, I have used the scandir and it seems to be picking out all the images in my folder but it is just showing 7 images boxed with no images.

Also, do you know how to align the images in a row so that on row 1 there are 3 images, on row two there are 3 images, and so on...

Thanks

Carl

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...