Forum Moderators: coopster

Message Too Old, No Replies

Image display

From a set of thumbnails

         

moonbather

12:03 am on Nov 2, 2003 (gmt 0)

10+ Year Member



Hello,

Some of my web pages contain thumbnail images and an image "container" (usually a large table cell). By clicking on a thumbnail, its corresponding full-size version is displayed in the container.

I have been using client-side scripting to do this, but I'd be interested to find out a good way of doing it with PHP.

Thanks for your interest.

jatar_k

12:22 am on Nov 2, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think the client side solution in this case is the best approach. All of the interaction is happening on the client side from your description.

For php to change img's etc, you would have to reload the page since it's server side.

NickCoons

2:47 am on Nov 2, 2003 (gmt 0)

10+ Year Member



moonbather,

I would have to agree with jatar_k.

Each has it's advantages. PHP will be faster for the client when the page loads initially because it will only load the large image that is currently being displayed. But JavaScript will be faster once it has loaded even though it will take a few extra seconds to load initially. This makes it easier, faster, and more intuitive for the user to use.

Personally, I'd stick with the client-side solution.

moonbather

3:36 pm on Nov 4, 2003 (gmt 0)

10+ Year Member



Thank you for your comments. One might say Javascript was born to do this, but I'd like to see if it's possible to do good image displays for users not having that.

I tried making the selected full size image display in an iframe,


<a href="mypic1.jpg" target="my_iframe"><img src="thumbnail1.jpg"></a>
<a href="mypic2.jpg" target="my_iframe"><img src="thumbnail2.jpg"></a>

but the results were not good.

I found that there is a margin between the top and left sides of the iframe, and the image (so the iframe has to be bigger than the iframe).

I suppose one way to solve that would be to have a page generated - which contained the full size image - with a margin-top: and margin-left: of 0px - and load that into the iframe.


<a href="mypic1.php" target="my_iframe"><img src="thumbnail1.jpg"></a>

So mypic1.php would contain mypic1.jpg,
mypic2.php would contain mypic2.jpg
etc.

I wondered if it would be possible to generate a page for each image in a directory (mypic1.php for mypic1.jpg, etc).

jatar_k

4:28 pm on Nov 4, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



generate a page for each image in a directory

absolutely. Do you want to have it automated?

Have a template for it and just get the names of all the images, slap the image name into the template, save the file with the image name as the filename.

broniusm

4:49 pm on Nov 4, 2003 (gmt 0)

10+ Year Member



moonbather-

I once wrote a php script to do some thumbnailing.

The script will go thru the passed-in directory, pick out the JPGs, check for thumbs of each pic and if it doesn't exist create them, then display a simple table of the thumbs linked to the original file directly. An alternative would be to link it to an image-display script which takes in only the image name as a parameter.

Lemme know if you'd like the script for grins.

-bronius

[edited by: jatar_k at 5:00 pm (utc) on Nov. 4, 2003]
[edit reason] no personal urls thanks [/edit]

moonbather

5:38 pm on Nov 7, 2003 (gmt 0)

10+ Year Member



jatar_k, broniusm, thank you for your replies.

My PHP knowledge level is quite low. jatar_k, I wondered if you could outline what functions I would use to produce a solution as you described. Is there any reference online?

I'm looking into image gallery scripts, but they might be over-complicated for my needs.

Birdman

12:19 am on Nov 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's pretty simple. Your images should be named in a consistent format like: foo.jpg(large)..foo_th.jpg(thumb). All your thumbs will be the same filename as the original with some identifier appended to it.

Example:

Thumbnail page


<a href="image_enlarge.php?image=foo_th.jpg"><img src="foo.jpg" /></a>

image_enlarge.php


<html>
...Your layout stuff here...
<img src="<?=$_GET['image']?>" />
...More layout stuff here...
</html>

Birdman