PrettyPhoto by the folks over at No Margin for Errors has been my go-to lightbox tool for a long time. I use it on most of the WordPress themes I develop. One thing that has always bothered me though, was that I found the placement of the text information in the popup counter-intuitive.
By default PrettyPhoto places whatever value is in the image’s ALT tag as a title across the top of the popup window, and it uses the contents of the link’s TITLE tag as the description under the photo. Now, common SEO practice is to use descriptive text and keywords in all your images ALT tags. In my opinion, PrettyPhoto’s default behavior encourages you to sacrifice your SEO best practices to get information to display correctly in the popup window. So I wanted it to behave differently.
I went looking for a solution and couldn’t find anything online about it specifically. Some folks had posted the same question on a few forums, but I didn’t find any answers. After some more digging on my own, it turns out to be pretty simple to swap the information’s positions. When you initiate PrettyPhoto in jQuery, one of the options is to tell photo the markup you want to use for your popup. I found that I just had to switch a pair of class names in that code, specifically the .ppt and .pp_description classes. Once I did that, the PrettyPhoto script that inserts the information would then behave how I wanted. Continue reading