Forum Moderators: coopster
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.
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.
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).
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]
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.
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