Upgrade from your WordPress admin panel, or download from wordpress.org/extend/plugins/add-rel-lightbox/

Version 0.4 switches from identifing the link-wrapped images in a page with hacked-together regexes that just about work, to properly parsed HTML structure using PHP Simple HTML DOM Parser.

When I initially tried to release version 0.4 and installed the updated plugin on this site, suddenly the content for half the posts stopped being displayed. After retracting the update, having a small panic, and reviewing the code that had been working without error in testing, I eventually found the culprit of the missing content: a regex in another plugin!

It turns out that the Simple HTML DOM Parser is set to strip linebreaks from the HTML input as standard. It was this operation, on content that otherwise was not altered by add-rel-lightbox that was breaking a (.*?) heavy regex. See also: Death to Dot-Star!

I've now changed add-rel-lightbox to leave the linebreaks in the content, so it will return content completely untouched if there are no link-wrapped images in the post. This means that it will play nicely with with other plugins but, if nothing else, this is a good example of why HTML should be parsed properly instead of using regular expressions for all but the most predictable content.


The couple of questions on the plugin's support forum suggests that add-rel-lightbox is being used with less lightbox-compatible image handlers, so it's probably a good time to add some configuration options for the plugin. Nothing too complex; just some variables that can be stored so they don't get overwritten by a plugin update.