News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Need Some Help Implementing a Lightbox

Started by 19eighties, July 17, 2014, 02:36:54 PM

Previous topic - Next topic

19eighties

I am making a couple tweaks to my forum, and one is adding a lightbox to attached images and images that are posted with BBC in posts. I figured out how to modify the template file so attachments have the rel="lightbox" attribute in the link wrapped around the image, and it is working well. But I am not sure how to alter the code that parses the images in the forum. I would like to wrap any image that someone links from an outside image host with a link to the image and include the rel="lightbox" attribute. However, I do not want signature images to be included in this modification. I am guessing I need to do something in the Subs.php script here:

array(
'tag' => 'img',
'type' => 'unparsed_content',
'parameters' => array(
'alt' => array('optional' => true),
'width' => array('optional' => true, 'value' => ' width="$1"', 'match' => '(\d+)'),
'height' => array('optional' => true, 'value' => ' height="$1"', 'match' => '(\d+)'),
),
'content' => '<img src="$1" alt="{alt}"{width}{height} class="bbc_img resized" />',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
'disabled_content' => '($1)',
),
array(
'tag' => 'img',
'type' => 'unparsed_content',
'content' => '<img src="$1" alt="" class="bbc_img" />',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
'disabled_content' => '($1)',
),


How can I wrap images in posts (and not signature images) with a link? A bonus would be if I can also use the width/length of the image to filter out small images that don't really need to pop-up in the lightbox.

Advertisement: