WordPress Version: 3.3.1
NextGEN Gallery Version: 1.9.3
Plugin Author: http://alexrabe.de/wordpress-plugins/nextgen-gallery/
NextGEN Gallery [nggallery id=x template=caption] Bug
See the NextGen Caption Bug post for details of this problem and its impact.
NextGEN Gallery [nggallery id=x template=caption] Fix
The problem occurs in a number of NextGen programs including /view/gallery-caption.php, /view/singlepic/php and /widgets/widgets.php.
The ‘must change’ two for me are /view/gallery-caption.php and /view/singlepic/php as they caused visual problem with my Nextgen galleries.
I haven’t provided a fix to /widgets/widgets.php as the only impact from that I’ve noticed is puttng lots of junk into my page source. I’m trying to keep my customising to a minimum so that one can stay.
Basically the fix requires occurrences of the variables ‘description’, ‘caption’ and ‘linktitle’ to be changed to ‘alttext’ whenever they are used as titles and alt text in <href> or <img> statements. I first made these changes a long time ago and from memory had 404 errors occur when viewing the gallery (although I may have also may other changes at the same time). Either way, updating permalinks resolved that.
Here’s before and after screen caps to show what a difference the changes below made.
The following code was run through a converter to allow it to be viewed as text on this page – hopefully the syntax is still correct. Between the two programs I only changed three words so personally I would change those manually rather than cut/paste the whole snippet.
Nextgen Gallery /view/gallery-caption.php
Original
<div class="ngg-gallery-thumbnail" >
<a href="<?php echo $image->imageURL ?>" title="<?php echo $image->description ?>" <?php echo $image->thumbcode ?> >
<?php if ( !$image->hidden ) { ?>
<img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
<?php } ?>
</a>
<span><?php echo $image->caption ?></span>
</div>
Updated
<div class="ngg-gallery-thumbnail">
<a href="<?php echo $image->imageURL ?>" title="<?php echo $image->alttext ?>" <?php echo $image->thumbcode ?> >
<?php if ( !$image->hidden ) { ?>
<img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
<?php } ?>
</a>
<span><?php echo $image->alttext ?></span>
</div>
Nextgen Gallery /view/singlepic.php
Original
<a href="<?php echo $image->imageURL ?>" title="<?php echo $image->linktitle ?>" <?php echo $image->thumbcode ?> >
Updated
<a href="<?php echo $image->imageURL ?>" title="<?php echo $image->alttext ?>" <?php echo $image->thumbcode ?> >
Hi. Looks like you have one too many g’s in your codes above – “nggg”. Anyhow, I got the captions to appear using your fix, so good deal! But, I’m also trying to display videos, and when using the shortcodes: [nggallery =id x] I get the videos, but no captions. [nggallery id=x template=caption] gives me the captions, but no videos. I want both – the caption and the video. Here’s a link to the page I’m working on to show you: http://www.harmonygardens.net/media/
Thank you!
Glad the post was of help. Thanks for pointing out my typo on the Nextgen gallery shortcodes. I can’t help with the captions for the videos as I’ve never used that functionality (I didn’t even know it existed). All I could suggest would be to test one video where you put some text in the Alt & Title field (the single line input box – no html allowed) and some different text in the large multi-line Description field (html allowed). Then check to see if anything appears under the video when using the [nggallery id=x template=caption] shortcode. There are issues in NextGEN where it incorrectly handles Alt/Title/Caption/Descriptions.
Thanks.
I added captions. But for some pictures the captions are longer, so the images on the page are not properly aligned. They appear jumbled…How to correct this ?
Can you can provide a url to a page exhibiting the problem?
this dosent works for me 🙁
Can we download a new NextGen Gallery with the fixed captions bugs already coded
Thanks for your code – it is now working
That’s great. We’re glad you found our site helpful.
These suggestions are totally useless in the latest version of NExtGen. Ridiculous that alttext and file name can’t be turned off on a hover. Just in light of the Public Upload it is unconscionable – as member of the public can upload a file with any name, but they can TYPE in a nice description. The Description showing on hover should be the default if anything.
Hi Ed,
I don’t use the latest version of NextGEN and have no plans to do so given the issues I have with it so any tips/tricks/customisation only applies to the version listed – 1.9.3 – and earlier.
Regards, Mike.