Wednesday, June 1, 2011

Lightbox Issues

I decided to use Lightbox to display a simple list of images in a slightly more elegant way than just a boring ol' href.

However, I couldn't get it to work! It kept trying to push the images down to below the bottom of the main content and then wouldn't "un-grey" it properly so it could be used. Basically, the lightbox effect was broken.

After a long time of debugging (wherein I was a bit distracted because of a missing image file), I finally figured out the problem. I'm using .htaccess to change the css handler from the normal page to the PHP engine. All I had to do to fix the problem was add the following line to the top of the lightbox.css file:

<?php header("Content-type: text/css; charset: UTF-8") ?>
Boom. Done. Works like a charm now.

(p.s. Here's the Lightbox website: http://www.lokeshdhakar.com/projects/lightbox2/. Yes, it does work as easily as they suggest; you just have to not screw around behind the scenes).