Simple Lightbox 1.3: Customizable Labels & Per Post Slideshows

With a dash of menu organization and a pinch of reset settings for a special flavor
By Sol in Lab

The primary purpose for this update to Simple Lightbox was to add a couple user-requested features, but at the last moment, I decided to add a couple additional features to improve usability.

Customizable Labels

Label Customization Options

Timo requested the ability to customize the text labels in the viewer (next, prev, etc.). This definitely makes sense for non-English websites as the lightbox’s default English text would be out of place. I added options for all customizable text the UI and the lightbox can now be (nearly) fully localized for any language.

Even if your site is in English, it’s also just fun to be able to customize the label text to say whatever you want.

Customized Labels

As I said, the lightbox’s UI can be nearly fully localized. The reason for this is that some parts of the UI use images that contain text instead of actual text.

Images in Lightbox UI

Currently, if a user wants to modify these parts of the UI, they can simply replace the files in the plugin’s images directory. However, the ultimate goal of this plugin is keep the user from having to mess with files directly, so a future update will allow the images in the UI to be customized as well. A couple of the solutions currently in the running are:

  • Replace images with actual text
    • Use CSS to style the text to match the images
    • Pro: User just needs to type the text they want to display
    • Con: Style (e.g. prev/next buttons) cannot be customized
  • Upload replacement images
    • Pro: Use any image to adjust theme of buttons
    • Con: Users must first create graphics

Feel free to leave a comment if you have a preference or any other suggestions.

Post-based Slideshows

Kurt requested the ability to limit the images in the slideshow to the latest post when viewing a page with multiple posts (e.g. on the homepage). Prior to this version, users had to the option to group all image links on the page into a single slideshow, making it simple to navigate through all of the image links on a page. However, if content from more than one post was displayed on a page, images from the different posts would be grouped into the same slideshow, resulting in a slideshow of potentially unrelated images. With this update, users now have the option to separate images by the post they’re in. When the user clicks a link to display an image in the lightbox, the slideshow (or prev/next buttons) will only cycle through the other images in the same post as the image that was clicked.

Group by Post Option

Settings Organization

Settings Organized

The admin settings were getting a bit crowded after adding the fields to customize the label text, so I decided to break up the settings with sub-headings for the different group of fields (activation, labels, etc.). Once again, I was happy that I took the time to automate the settings UI generation as I only needed to add an additional entry to an array for each sub-heading and modify the code to output these entries as headers instead of fields.

'header_enabled' => 'Activation' //Adds sub-heading to settings UI output
...fields under this sub-heading

Total time to implement this was probably under 5 minutes.

Reset Settings

Reset link in Plugin Listing

This feature wasn’t really necessary at this point, but as the list of customizations grow, it will become more and more useful. Basically, it’s a quick way to reset the plugin’s settings to their default values. This can be especially useful if you’ve made some undesirable changes and you just want to start fresh. This is a destructive operation (as all of your customizations are removed) so it is protected by a confirmation popup and a nonce to make sure that you really want reset your settings.

Thanks again to Timo and Kurt for the feature suggestions. These additions make the plugin even more customizable while still keeping things simple.