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);

Share This Link: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Reddit
  • del.icio.us
  • De.lirio.us
  • Netscape
  • YahooMyWeb
  • Furl
  • Spurl
  • Fark
  • Book.mark.hu
  • NewsVine
  • Ma.gnolia
  • Wists
  • Smarking
  • feedmelinks
  • Technorati
  • Slashdot
  • SphereIt
  • Blue Dot
  • StumbleUpon

One Response to “Tweaking the NextGEN Gallery Plugin”
  1. Jacob Stoops says:

    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

Leave a Reply

Subscribe without commenting