Forum Moderators: mack

Message Too Old, No Replies

Image gallery how to?

How to avoid one page per image

         

kate theisinger

3:16 pm on Jul 13, 2005 (gmt 0)

10+ Year Member



I have a site with galleries showing thumbnail images, and the plan is for visitors to click through for a better look at the image. Unfortunately the only way i know to do this is to build a new page to display each image - and with upwards of 60 images on the site this would be pretty labour intensive and i have a feeling there must be an easier way....?

This may be too complicated to explain here, but any pointers in the right direction would be great.

Thanks!

mack

5:13 pm on Jul 13, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If you have the ability to use PHP/CGI on your host you migh want to think about using an image gallery script. I have used a few of these in the past and they can save you a lot of time and hard work. There are many different scripts than can do this but generaly they all follow the same pattern.

You place all your images in a folder, the script then creates a small version of each on the fly to display in a gallery, it then opens the full image when a smaller version is clicked on. This will prevent you from having to manualy make the small version and large version for each of your images.

You might want to have a look through hotscripts.com for a suitable script.

Mack.

richlowe

10:07 pm on Jul 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use a product called Thumbsplus (and there are many other products) which will create all of the pages based upon a template. I can do several thousand pages/images in an evening exactly the way I want.

Tomness

10:18 pm on Jul 13, 2005 (gmt 0)

10+ Year Member



Unfortunately the only way i know to do this is to build a new page to display each image.

Yes, I had the same problem with photo gallerys that were updated frequently - it became quite tedious doing it every week, and so I got myself an automated php script that really requires almost no knowledge of php to use.

You place all your images in a folder, the script then creates a small version of each on the fly to display in a gallery, it then opens the full image when a smaller version is clicked on.

It appears Mack uses a similar, if not, the same script as me - because the thumbnails are the images themselves, just resized, once they're clicked, the loading is almost instant.

Here is a short, yet dandy php code I use to generate an image galler. CSS compliments it well and make it appear well optimized.

This is an example I have taken from one of my photo gallerys.

yourphotogallery.php

<html>
<head>
<title>your page</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>

<body id='gbody'>

// you can add any html you like to this. Wrapping it in a well styled div and giving it a nice header is always good.

<?
$NAMEFILE = "index.php"; //This files name.

$dir = opendir("."); //Replace the dot with ./yourfolder or leave it as it is. This is the folder that the images are taken from.

while ($file = readdir($dir)) {
if ($file!= "." && $file!= ".." && $file!= "$NAMEFILE") {
$time = filemtime("$file");
$data[$time] = "<a href=\"$file\" target=\"new\"><img src=\"$file\" width=\"#\" height=\"#\"></a>
";
}}

krsort($data);
while(list($k,$v) = each($data)) { echo $v; }
clearstatcache();
?>
</body>
</html>

I have added comments to the basics (what you will need to know most of all) and I have made the image proppertys bold.

Just replace the hash signs with the appropriate data. You can add borders too if you wanted, even an image class or id if you're using CSS.

Hope that helped.