WordPress.org

Ready to get started?Download WordPress

Forums

Lightbox 2 plugin kills certain link tags (1 post)

  1. michaeltyson
    Member
    Posted 4 years ago #

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

    <a href="http://farm5.static.flickr.com/4039/4337325635_0ecca22f1a.jpg" class="thickbox" rel="lightbox[flickr]"
                        title="Douz animal market | <a href=&quot;http://www.flickr.com/photos/michael-tyson/4337325635&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;
    }

    http://wordpress.org/extend/plugins/lightbox-2/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags