SLB: Gallery Support

By Sol in Lab

It’s been a while, but I finally had some time today to make some updates to Simple Lightbox.  Most of my attention was given to the move (which was really more of a renovation and then a move), which is still ongoing (in fact, I’m heading out to do more work after I post this).  Nonetheless, there were a few little issues that have been bugging me that I’m glad that I was finally able to sit down for a few minutes and knock them off my mental list.

On to what’s new in the update:

Gallery Support

This was an oft-requested feature and one that frankly should have been there from the start.  Implementation was easy peasy:

Before

add_filter('the_content', $this->m('activate_post_links'));

After

add_filter('the_content', $this->m('activate_post_links'), 99);

Basically, galleries in WordPress are added via shortcodes, and the shortcodes in post content are processed with a filter priority of 12.  Originally, SLB’s link activation did not specify a priority, and thus was given the default priority of 10.  As a result, SLB activated all links in a post before any gallery shortcodes were expanded to their final HTML markup.

Changing the priority of SLB’s link activation to 99 assures that it comes after shortcodes have been processed, as well as most other post filters, so that there is a much better chance that all links in a post’s final output can be activated.  It’s kind of a brute force approach, but like I said, I had some time, not a lot.  Ultimately though, while this is “good enough,” I’d like to implement a more elegant approach that makes sure that link activation does not occur until all other filters have done their job on the post’s content.

Navigation Links

One of the silly bugs from the previous jQuery integration of SLB was that the navigation buttons (next, previous, start/stop slideshow) were displayed even when there was only one image in the post.  Though several people were asking for gallery support, this issue was the one that was eating away at me.  It was a silly oversight and it was hard not to sit down and rectify it for the past month.  Well, it wasn’t that difficult seeing as how my computer was in a box for the past month.

User-defined UI Text

Another bug from the jQuery integration.  However, I didn’t even know about this one until today.   I reconnected the wires and now user-defined text is back in full effect.  Rejoice!

Next up for SLB: options overhaul.  It’s mostly internal plumbing that will be changed, but it will make it easier to add more options in the future, which will of course benefit you.