Fair Warning: This one gets rather technical. But if a PHP Neophyte like me I can figure it out, anyone who has installed their own WordPress blog should be able to handle it.
After installing the NextGEN Gallery plugin to better manage photos on this blog, we discovered just one issue we didn’t like about it. Viewers could only see the first six (our image maximum number set in the preferences) photos at full size when clicking on a thumbnail even if there were multiple sub-pages of photos.
I found this quick fix in the NextGEN forums which requires editing the nggfunction.php file. I include the required code modifications below for your convenience, or confusion if that may be the case. Just be sure to make a backup copy of your nggfunction.php file first!
One more note of caution: For galleries with hundreds of photos, modifying the plugin this way may cause extra strain on the server when calling the page since all the thumbnails will load at that time.
DISCLAIMER: No promises here. I take no credit for this and accept no liability if it doesn’t work for you. It did for me.
Download as a text file: NextGEN Gallery Plugin Modifications
1. Add this new function: (Not sure if it matters where, I added it right after function nggShowGallery.)
/**********************************************************/
function createNoShows($noshows, $thumbcode){
$return = ”;
if (count($noshows) > 0) {
$return .= ‘<div style=”display: none;”>’;
foreach ($noshows as $pic) {
$folder_url = get_option (‘siteurl’).”/”.$pic->path.”/”;
$picturefile = nggallery::remove_umlauts($pic->filename);
$link =($ngg_options[‘galImgBrowser’]) ? htmlspecialchars(add_query_arg(array(‘page’=>get_the_ID(),’pid’=>$pic->pid))) : $folder_url.$picturefile;
$return .= ‘<a href=”‘.$link.'” title=”‘.stripslashes($pic->description).'” ‘.$thumbcode.’ ></a>’;
}
$return .= ‘</div>’.”\n”;
}
return $return;
}
2. In function nggCreateGallery find
array_splice($picturelist, 0, $start);
before this add:
$noshows_before = array_slice($picturelist, 0, $start);
3. In function nggCreateGallery find
array_splice($picturelist, $maxElement)
before this add:
$noshows_after = array_slice($picturelist, $maxElement);
4. In function nggCreateGallery find
foreach ($picturelist as $picture) {
before this add:
$out .= createNoShows($noshows_before, $thumbcode);
5. In function nggCreateGallery find
$out .= ($maxElement > 0) ? $navigation : ‘<div class=”ngg-clear”></div>’.”\n”;
before this add:
$out .= createNoShows($noshows_after, $thumbcode);
After a late night last night, I figured out how to modify version 1.0.2. Here’s the discussion and instructions on the WordPress forum…
http://wordpress.org/support/topic/228743
Steve
Thanks for the warning!!! Another reason not to upgrade. 😉
For what it’s worth, this modification does not work with the latest version of the Nextgen Gallery (1.0.2) of this post. It does work with v0.99 which I was using. Upgrading to the new version broke it and the newer code is way different.
Steve
Thanks for the help on this one. One small issue I found. I downloaded the text file, and in it, the last instruction requires that you put in:
$out .= createNoShows($noshows_after, $thumbcode);
The line should really be:
$out .= createNoShows($noshows_after, $thumbcode);
Without the tag. Looks like perhaps a cut and paste error?
Great article. Hopefully I can get it to work with some of my galleries. I use this plugin all the time and some of the biggest issues I have comes with the display of the thumbnails.
Also, I’ve spent some time working on getting the gallery to display in the header…as there was no clear tutorial on alex.rabe’s site about how to do it. You’ve helped me, now maybe I can help you. Here is the tutorial on implementing the NEXTGEN Gallery into the WordPress header.php file