I have a slightly older version of NGG because I have modded it and have yet to transfer those mods to the latest version. But I just made another minor change that I wanted to document before I forget what I did.
Using the
no images were found
works well for showing the images from the gallery that are tagged as an automated gallery creation.
But I wanted to get the captions displayed as well like the syntax for the standard gallery by id display
no images were found
. So I needed to add the ” template=caption” as an option for the nggtags shortcode.
Edit /wp-content/plugins/nextgen-gallery/nggfunctions.php
Around line 867 should start the function into which I inserted the $template value (with relevant comma’s etc.) at 3 places as highlighted with the new text.
[php highlight=”1,13,23″]
function nggShowGalleryTags($taglist, $template = ”) {
// $_GET from wp_query
$pid = get_query_var(‘pid’);
$pageid = get_query_var(‘pageid’);
// get now the related images
$picturelist = nggTags::find_images_for_tags($taglist , ‘ASC’);
// look for ImageBrowser if we have a $_GET(‘pid’)
if ( $pageid == get_the_ID() || !is_home() )
if (!empty( $pid )) {
$out = nggCreateImageBrowser( $picturelist, $template);
return $out;
}
// go on if not empty
if ( empty($picturelist) )
return;
// show gallery
if ( is_array($picturelist) )
$out = nggCreateGallery($picturelist, false, $template);
$out = apply_filters(‘ngg_show_gallery_tags_content’, $out, $taglist);
return $out;
}
[/php]
That sorts out the function that is called from the /wp-content/plugins/nextgen-gallery/lib/shortcodes.php
Around line 114 there is a string evaluation test process that we change to look for a second option referenced as template= etc.. shown in the highlighted line.
[php highlight=”6″]
if ( stristr( $content, ‘[tags’ )) {
$search = "@(?:<p>)*s*[tagss*=s*(.*?)s*]s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$replace = "
no images were found
}" template="{$match[2]}"]";
$content = str_replace ($match[0], $replace, $content);
}
}
}
[/php]
Finally around line 273 there is the call to the nggShowGalleryTags in the show_tags function. Insert a new line for $template as a parameter and to the output option.
[php highlight=”5,12″]
function show_tags( $atts ) {
extract(shortcode_atts(array(
‘gallery’ => ”,
‘template’ => ”,
‘album’ => ”
), $atts ));
if ( !empty($album) )
$out = nggShowAlbumTags($album);
else
$out = nggShowGalleryTags($gallery, $template);
return $out;
}
[/php]
Now the nggtags option that will create a custom gallery from Tagged images can optionally include the image caption as well.