Open galley in Lightbox or PrettyPhoto for NextGEN Gallery

First add the following nggGetGallery() function to functions.php file:

[code language=”css”]

function nggGetGallery( $galleryID, $template = ”, $images = false ) {

global $nggRewrite;

$ngg_options = nggGallery::get_option(‘ngg_options’);

//Set sort order value, if not used (upgrade issue)
$ngg_options[‘galSort’] = ($ngg_options[‘galSort’]) ? $ngg_options[‘galSort’] : ‘pid’;
$ngg_options[‘galSortDir’] = ($ngg_options[‘galSortDir’] == ‘DESC’) ? ‘DESC’ : ‘ASC’;

// get gallery values
//TODO: Use pagination limits here to reduce memory needs
$picturelist = nggdb::get_gallery($galleryID, $ngg_options[‘galSort’], $ngg_options[‘galSortDir’]);
return $picturelist;


Next created a new template inside plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/view named album-lightbox.php:

[code language=”css”]

Template Page for the album overview
Created By: Sandeep Paul
Created on:13.8.14

Follow variables are useable :

$album : Contain information about the album
$galleries : Contain all galleries inside this album
$pagination : Contain the pagination content

You can check the content when you insert the tag <?php var_dump($variable) ?>
If you would like to show the timestamp of the image ,you can use <?php echo $exif[‘created_timestamp’] ?>
<?php if (!defined (‘ABSPATH’)) die (‘No direct access allowed’); ?><?php if (!empty ($galleries)) : ?>

<div class="ngg-albumoverview">

<!– List of galleries –>
<?php foreach ($galleries as $gallery) : ?>

<div class="ngg-album-compact">
<div class="ngg-album-compactbox">
<div class="ngg-album-link" id="<?php echo $gallery->name ?>">
<?php $images = nggGetGallery( $gallery->gid );
$imgcntr = 0;
<?php foreach ( $images as $image ) : ?>
<?php if ( $imgcntr == 0 ): ?>
<a href="<?php echo $image->imageURL ?>" title="<?php echo str_replace(""", "’", $image->description); ?>" <?php echo $image->thumbcode ?> >
<img class="Thumb" alt="<?php echo $gallery->title ?>" src="<?php echo $gallery->previewurl ?>"/>
<?php $imgcntr++; ?>
<?php else: ?>
<a href="<?php echo $image->imageURL ?>" title="<?php echo str_replace(""", "’", $image->description); ?>" <?php echo $image->thumbcode ?> ></a>
<?php endif; ?>
<?php endforeach; ?>
<h4><a class="ngg-album-desc" title="<?php echo $gallery->title ?>" href="<?php echo $gallery->pagelink ?>" ><?php echo $gallery->title ?></a></h4>
<?php if ($gallery->counter > 0) : ?>
<p><strong><?php echo $gallery->counter ?></strong> <?php _e(‘Photos’, ‘nggallery’) ?></p>
<?php endif; ?>

<?php endforeach; ?>

<!– Pagination –>
<?php echo $pagination ?>


<?php endif; ?>


This was based off of the album-compact.php template. The format for adding galleries is now:

[album id=7 template=lightbox]

Then install preetyphoto media plugin


Then I go Gallery -> Options -> Effects, changed the dropdown to Custom, and added this code:


Get the Complete Code

Download for Github

Sandeep Kumar

Sandeep kumar is a web developer and a professinal blogger. He works for latest technologies and write articles what he learn. In ICodeHub he share web languages tutorials and other programming tips and tricks. if you need some help or have some suggestion then mail him at sandeep92pal@gmail.com without any hesitation. He believes in learning and sharing.