Lightbox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dddmx3
Forum Newbie
Posts: 16
Joined: Mon Sep 20, 2010 9:05 pm

Lightbox

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Lightbox

Post 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.
(#10850)
dddmx3
Forum Newbie
Posts: 16
Joined: Mon Sep 20, 2010 9:05 pm

Re: Lightbox

Post by dddmx3 »

Sorry not so good at PHP, but do I just add that at the end of my code?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Lightbox

Post by Christopher »

You would add it before you use $image->image_full because that is the variable it sets (with "_LRG" in the name).
(#10850)
dddmx3
Forum Newbie
Posts: 16
Joined: Mon Sep 20, 2010 9:05 pm

Re: Lightbox

Post 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>
Post Reply