Galleries Are Fixed Now — NextGEN Gallery Not Displaying Thickbox Images

After laying down for bed, I had an epiphany last night and got up and based away at the keyboard for a bit. Luckily, the effort wasn’t wasted, as I was able to fix the issue that caused the problem in the first place.

The long story boiled down is that the ThickBox can find a “group” of images if you pass it common name in the rel param in your a tag. For instance:

That’s simple enough. Any link that has the rel param set to “anyString” will be shown with Thickbox having “next” and “prev” links so you don’t have to view, close, open the next by hand. Very handy feature, for sure!

However, if the rel param happens to have a space in it, this appears to break completely, resulting in the image not being displayed. I’m sure there’s some degree of bug on Thickbox’s side, but I decided to fix it on the NextGEN Gallery side since that’s code I’m far more familiar with.

The fix is rather simple. In /wp-content/plugins/nextgen-gallery/lib/image.php, find the line:

function get_thumbcode($galleryname = ”) {

Immediately under that, add the following two lines:

 // Fix thickbox failure when $galleryname has a space in it
$galleryname = preg_replace( ‘/\s+/’, ”, $galleryname );

And that’s it. That strips the whitespace from the $galleryname variable which is what’s passed on to the code that populates the rel param in image links for Thickbox.

Just keep in mind that if you make this change on your server, your changes will be overwritten when you perform your next update — so make a note and be sure to apply this fix again after you upgrade.

Jul 27th, 2011 | Posted in Nerd, Photography, Site News
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>