**New for version 0.3:

  • Adjusted the filter hook priority so it uses the core [gallery] shortcode function.

  • Also works with the_extract() e.g. on front page and category listings.

  • All images and gallery form one linked gallery per post/page.

Search for “add-rel-lightbox” from your WordPress installation or download the source from:


Where version 0.2 added the capability for add-rel-lightbox to add attributes to image links from the WordPress [gallery] shortcode, it did replace the WordPress core gallery_shortcode() function. Clearly, replacing a function means having to keep the plugin code updated if there are any changes to the relevant core code, so it's not an ideal solution. However, at the time, I didn't know how to ensure the link filter ran after the gallery shortcode.

The answer is in the WordPress codex (codex.wordpress.org/Shortcode_API), where it states:

do_shortcode() is registered as a default filter on 'the_content' with a priority of 11.

So just setting add-rel-lightbox's filter priority means it will run after all shortcodes by default, and the core gallery_sortcode() can be used.

Also from a suggestion from Jason Spatola, version 0.3 also works with the_excerpt, so images in post excerpts also have lightbox attributes added. But so that all the images on the page aren't called in one single gallery, the rel="lightbox" now has includes the post number.

<a href="/url/to/ima.ge" rel="lightbox[post-$id]" title="Media description"><img…></a>

Gallery images are also supplemented by post ID, so all local embedded images form one linked gallery per post. <!-- more -->

Future Development

I've intentionally left out parsing images in comments, and any images from non-embedded locations for this version. In my view, more options need more choices, so the plugin next needs a settings page so administrators can choose what groups of links should be parsed and if they should be a linked gallery.