PDA

View Full Version : using image thumbnail viewer with images stored in a database



jmg666
02-15-2010, 05:12 PM
1) Script Title: Image Thumbnail Viewer II

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/thumbnail2.htm

3) Describe problem: I've got a listings page where thumbnail images for each item are being pulled from a database table - there's scope within the page for a maximum of 10 images to be used, with the first photo in each listing being located in the "loadarea" div.
Ideally what I want is for the user to be able to click on image2 through image10 (or however many there are) and have the larger version of each one come up in "loadarea".
Initially I had problems with getting "missing image" icons appearing, but thanks to an IF ELSE statement, nothing shows if there's nothing in the database for that particular image.
Is it going to be possible to amend the code for ITVII to get this to work with dynamically generated images? I can see how easy it would be with static images pulled from an images folder but can't quite get my head round how to tie this into the existing code for this page.
Any assistance appreciated.

jscheuer1
02-15-2010, 06:58 PM
I don't know a whole lot about what you are talking about. However, all dynamically generated images I've seen are generated with PHP. There is a PHP file with code in it that generates the image using one or more of the various PHP image commands and usually other PHP code. That filename and its query string may then be used as an image. So say your file was:

imgGen.php

and to get it to make a particular image you have to pass it a number:

imgGen.php?pic=22

If it's anything like that, all you have to do is arrange for strings like that to be generated by your other code and placed as the thumbnail's source and/or as the thumbnail's link's href, whichever ones you wish to be dynamically generated.

A query string need not be used, a post or session variable could carry the information, but probably wouldn't be practical in the type of scenario you are describing visa vis the thumbnail viewer.

jmg666
02-17-2010, 12:23 PM
John - thanks for the reply. What I'm having trouble getting my head round is how I can work the code which generates the images from the database into the coding for the viewer.
As you say, this is a php page, and to give an example, the code which pulls image2 into the page is:


<?php if(($row_DetailRS1['photo2'] != NULL) && ($row_DetailRS1['photo2'] != "")) { ?>
<a href="<?php echo $row_DetailRS1['photo2']; ?>"><img src="<?php echo $row_DetailRS1['photo2']; ?>" width="100" height="100" border="0" /></a>
<?php } else { echo "&nbsp;"; } ?>

I'm not clear what I would use with the viewer code...

jscheuer1
02-17-2010, 04:50 PM
<?php if(($row_DetailRS1['photo2'] != NULL) && ($row_DetailRS1['photo2'] != "")) { ?>
<a href="<?php echo $row_DetailRS1['photo2']; ?>" rel="enlargeimage::click" rev="loadarea"><img src="<?php echo $row_DetailRS1['photo2']; ?>" width="100" height="100" border="0" /></a>
<?php } else { echo "&nbsp;"; } ?>

Now the only potential problem I see is if you have more than one division with the id of loadarea, it's unclear from your posts, but I'm assuming you do not.

In any case, if you want more help:

Please post a link to a page on your site that contains the problematic code so we can check it out.

jmg666
02-17-2010, 10:11 PM
John - thanks, that works great, really appreciate the assistance.
I will be showing my appreciation in a more tangible form by making a donation as soon as payday rolls round next week.
Thanks again,
regards,
Jeff