nggShowRelatedGallery
Show related images for a post/page.
Description
Parameters (2)
- 0. $taglist (string)
- List of tags as csv
- 1. $maximages — Optional. (int)
- limit the number of images to show. 0=no limit
Usage
if ( !function_exists( 'nggShowRelatedGallery' ) ) { require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/nggfunctions.php'; } // list of tags as csv $taglist = ''; // (optional) limit the number of images to show. 0=no limit $maximages = -1; // NOTICE! Understand what this does before running. $result = nggShowRelatedGallery($taglist, $maximages);
Defined (1)
The function is defined in the following location(s).
- /nggfunctions.php
- function nggShowRelatedGallery($taglist, $maxImages = 0) {
- $ngg_options = nggGallery::get_option(ngg_options);
- // get now the related images
- $picturelist = nggTags::find_images_for_tags($taglist, 'RAND');
- // go on if not empty
- if ( empty($picturelist) )
- return;
- // cut the list to maxImages
- if ( $maxImages > 0 )
- array_splice($picturelist, $maxImages);
- // *** build the gallery output
- $out = '<div class="ngg-related-gallery">';
- foreach ($picturelist as $picture) {
- // get the effect code
- $thumbcode = $picture->get_thumbcode( __('Related images for', 'nggallery') . ' ' . get_the_title());
- $out .= '<a href="' . $picture->imageURL . '" title="' . stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) . '" ' . $thumbcode . ' >';
- $out .= '<img title="' . stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')) . '" alt="' . stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')) . '" src="' . $picture->thumbURL . '" />';
- $out .= '</a>' . "\n";
- }
- $out .= '</div>' . "\n";
- $out = apply_filters('ngg_show_related_gallery_content', $out, $taglist);
- return $out;
- }