Log in

View Full Version : Lightbox and PHP image code



Interact
04-11-2010, 10:07 AM
Hi there I wonder if some of you bright sparks can help me please?

I have a simple shopping basket that doesn't provide a image preview tool its very basic as its free) and I wish to use lightbox as a preview; I'm not a coder but I wonder if someone could look at the code below and tell me how I can fix it so it works with lightbox?

This is the php code that collects the product image:

<?php
if (is_file($SETTINGS["path"]."products/".$PRODUCT["image"])) echo "<img src='".$SETTINGS["URL"]."products/".$PRODUCT["image"]."' class='ProductImage' border='0'>";
?>

This is the code for lightbox to work:

rel="lightbox"

I've had a go myself and managed to have the lightbox window open but no image shows, this is the code:

<a href="#" border="0" rel="lightbox">
<?php
if (is_file($SETTINGS["path"]."products/".$PRODUCT["image"])) echo "<img src='".$SETTINGS["URL"]."products/".$PRODUCT["image"]."' class='ProductImage' border='0'>";
?></a>

Of course I know the # should be the link for the image but I just can't get it to work.

Please can someone help me here?

Thanks

Interact
04-11-2010, 12:24 PM
Not to worry guys, I figured it out looking around the forum here:

<a href="<?php echo ""."shop/products/".$PRODUCT["image"]?>" rel="lightbox" width="100%" border="0">
<?php
if (is_file($SETTINGS["path"]."products/".$PRODUCT["image"])) echo "<img src='".$SETTINGS["URL"]."products/".$PRODUCT["image"]."' class='ProductImage' border='0'>";
?></a>

Now to figure out how to have the lightbox image larger :) I'm getting there :)with the help of this forum.

liamallan
04-11-2010, 02:42 PM
try:

<?php
if (is_file($SETTINGS["path"]."products/".$PRODUCT["image"])) echo "<img src='".$SETTINGS["URL"]."products/".$PRODUCT["image"]."' class='ProductImage' border='0' height='400' width='400'>";
?>