Slideshows and Stuff

If you’ve been looking at my last post, or any older gallery posts, or indeed some of the recent posts with single images, you might have noticed some new tricks. Provided your paranoia level permits JavaScript on this site, when you click on an individual image[1] or thumbnail, rather than being taken to a page showing a medium size version, or just to the image, either of which would involve a lot of clicking to see all the images, you will now get a fancy box thingy containing a large version of the image. If you click a gallery thumbnail, you’ll be able to click through the images using the “next” and “previous” links, or start a slideshow and then sit back and watch all the images without further effort.

I had this kind of thing in mind when I started the process of moving images into WordPress, but until yesterday, I hadn’t really thought about how to do it. While there are a lot of very nifty gallery plugins available for WordPress, I wanted to use something that I could change or remove at any point without having to change a load of posts again[2]. I think it’s quite likely that some future release of WordPress will include slideshows as a native features, with nice hooks for themes to work with, so any plugin I used would need to “just work” without needing anything special done to gallery posts.

I searched the Plugins Directory, tried a few, and eventually settled on Lightbox Plus, which has plenty of options, and fills the “just works” requirement nicely. Well, it would have just worked if I’d set up all my galleries in the right way. When I created them, I’d left an option on its last used setting, which meant that clicking a thumbnail would take you to a page displaying the picture, which (depending on the theme used) might have some navigation to move backwards and forwards. For the fancy floaty box thingy to work, all the galleries would need to be set so that clicking a thumbnail would go straight to the image. Oh dear. Would I have to go into every gallery post and make yet another edit? Wouldn’t that be fun?[3]

Looking for an easier way, I found that all the existing gallery posts had a WordPress shortcode that looked like this: [gallery] and after editing a single post to make the thumbnails link to the images, it had a shortcode like this: [gallery link="file"].

Could it really be that simple? Well, yes. After a quick test on one of my spare sites, and making sure I had a good backup of the database, I used the nifty Search and Replace plugin to make that change in all posts. And it worked exactly as I’d hoped. Woo, hoo, etc.

Oh, and I had a bit of bother getting WordPress to let me include “[gallery]” in this post, as it kept wanting to interpret it as instruction to insert a gallery. I got round it with the wpNSC (No Short Codes) plugin.

And I’ve since found that it’s even easier than that – no plugins required! All you have to do to show a short code (or “escape WordPress shortcodes” as more programmery people would say) in your post is add an extra layer of brackets around it – [[gallery]], for instance[4]. Huge thanks to WordPress Plugin Fu for that tip, which has worked since WordPress 2.5, but doesn’t show up in too many searches.

Note: as I’m using a nested shortcodes plugin, I’ve had to add an extra layer of []s around all those!

[1] Except for small ones that are already at full size, that is
[2] I can think of better ways of spending numerous hours…
[3] Hint: :wah: :duh:
[4] And to show the double brackets, just type three of them. Superb.