Support » Plugins » Lightbox 2 plugin kills certain link tags

  • Hello!
    This plugin seems to mess with certain tags – the output from my plugin, flickrpress, for example:

    <a href="" class="thickbox" rel="lightbox[flickr]"
                        title="Douz animal market | <a href=&quot;;>View at Flickr</a>">

    I took a look into the Lightbox 2 plugin – the regex that performs the replacement is actually a tad clumsy and inflexible, hence the tag mangling.

    The following will do the trick; I’ve tested it on my site and it now works properly. It uses a negative lookahead to avoid performing replacement on tags with the lightbox “rel” value already, instead of performing the change, then ‘fixing’ it, which is what the prior regex was doing, mangling the tag in the process:

    function autoexpand_rel_wlightbox ($content) {
    	global $post;
    	$pattern        = "/(<a(?![^>]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i";
    	$replacement    = '$1 rel="lightbox['.$post->ID.']">';
    	$content = preg_replace($pattern, $replacement, $content);
    	return $content;

  • The topic ‘Lightbox 2 plugin kills certain link tags’ is closed to new replies.