If your site has several static images that
you want to showcase to your visitors, one option is to set up an
image gallery. News sites, like CNN, and Video Game sites, like IGN, use these galleries
when they have a group of photos connected to a specific
article.
The following code will help you set up an image gallery of your
own. It is fairly basic and will allow you to customize it to your
own needs. It also assumes that you are going to be using less than
20 images -- if you're going to use 20 or more images, you will
need to make a few changes to the SWITCH statement in the
javascript.
The first thing you need to do to get started is to set up your
images. If you are using digital photos, make sure to import them
into a graphics program, like Paint Shop Pro, and optimize the
images for web use (in most graphics programs, look for the
"Export" option, and make sure you set an appropriate compression
value).
Next, you want to set up a subfolder which will hold just the
images for your image gallery.
In the code on this page, you will need two copies of each of your
images. The original images should be saved in the format "pic0x"
-- the first picture would be "pic01.jpg", the twelth picture would
be "pic12.jpg".
The second copy of the image should be either cropped or resized
to about 20% of the original image's size. This will be your
thumbnail that will be first displayed to the user. The thumbnails
should be saved in the format "thumb0x". Thumbnail one would be
"thumb01.jpg", while thumbnail fifteen would be "thumb15.jpg". Of
course, you don't have to have thumbnails -- it will speed up
loading times for your visitors, but its not necessary. If you
don't want thumbnails, just drop the parts of the code that you
don't need.
First set up the javascript for your image gallery page:
Now, somewhere on your HTML page, you want the IMG tag and the
Labels that will allow you to move Forward and Backward:
Finally, here is the code for BIGPICTURE.HTML, the page that will
load your full-sized images:
To read a discussion of how to do this with ASP and Recordsets, read
this thread in our message boards!
Want to discuss this article, or other development issues? Visit our
message boards!
Or contact us directly with a comment or question on this article: click here !
|