Page 1 of 1

Lightbox

Posted: Mon Jun 06, 2011 8:21 pm
by dddmx3
This code here:

Code: Select all

<a class="lightbox" href="<?php print $this->image_product_path?>/<?php print $image->image_full;?>"><img class = "jshop_img_thumb" src = "<?php print $this->image_product_path?>/<?php print $image->image_thumb?>" alt = "<?php print htmlspecialchars($this->product->name)?>" /></a>
If you click on an image (For example test.png) it opens it in Slim Box. I'd for that code to be able to do this:
You click on "test.png" and "test_LRG.png" opens in slim box. Pretty much all I need to do to the code is somehow to tell it to add _LRG to the end of the image path.

To view the code above in action, go here: http://bit.ly/kpKJyK

Re: Lightbox

Posted: Tue Jun 07, 2011 12:44 am
by Christopher
For common image extensions, you could do something as simple as:

Code: Select all

$base_len = strlen($image->image_thumb) - 4;     // length without .png, .jpg, .gif, etc.
$image->image_full = substr($image->image_thumb, 0, $base_len) . '_LRG' . substr($image->image_thumb, $base_len, 4);
You could have the code check for extensions that were not three characters by searching for the last dot in the string and finding that position. You also might want to look into the pathinfo() function.

Re: Lightbox

Posted: Tue Jun 07, 2011 6:51 pm
by dddmx3
Sorry not so good at PHP, but do I just add that at the end of my code?

Re: Lightbox

Posted: Wed Jun 08, 2011 1:28 am
by Christopher
You would add it before you use $image->image_full because that is the variable it sets (with "_LRG" in the name).

Re: Lightbox

Posted: Sat Jun 25, 2011 10:33 am
by dddmx3
I'm so sorry, I don't get it. Can you just give me the code?
Basically all I need is to display a thumb image and when you click on it, it opens the "large" version. Scratch the lightbox.
For example:

<a href="<?php code goes here. This should link to the 'large' version of the image."><img src="images/this_is_the_thumb_image.png" alt=""</a>

Essentially, If someone were to look at my website's source code, the image code would look like:

<a href="test_LRG.png"><img src="test.png" alt=""</a>