nggShowRelatedGallery

Show related images for a post/page.

Description

nggShowRelatedGallery( (string) $taglist, (int) $maxImages = 0 ); 

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

  1. if ( !function_exists( 'nggShowRelatedGallery' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/nggfunctions.php'; 
  3.  
  4. // list of tags as csv 
  5. $taglist = ''; 
  6.  
  7. // (optional) limit the number of images to show. 0=no limit 
  8. $maximages = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = nggShowRelatedGallery($taglist, $maximages); 
  12.  

Defined (1)

The function is defined in the following location(s).

/nggfunctions.php  
  1. function nggShowRelatedGallery($taglist, $maxImages = 0) { 
  2.  
  3. $ngg_options = nggGallery::get_option(ngg_options); 
  4.  
  5. // get now the related images 
  6. $picturelist = nggTags::find_images_for_tags($taglist, 'RAND'); 
  7.  
  8. // go on if not empty 
  9. if ( empty($picturelist) ) 
  10. return; 
  11.  
  12. // cut the list to maxImages 
  13. if ( $maxImages > 0 ) 
  14. array_splice($picturelist, $maxImages); 
  15.  
  16. // *** build the gallery output 
  17. $out = '<div class="ngg-related-gallery">'; 
  18. foreach ($picturelist as $picture) { 
  19.  
  20. // get the effect code 
  21. $thumbcode = $picture->get_thumbcode( __('Related images for', 'nggallery') . ' ' . get_the_title()); 
  22.  
  23. $out .= '<a href="' . $picture->imageURL . '" title="' . stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')) . '" ' . $thumbcode . ' >'; 
  24. $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 . '" />'; 
  25. $out .= '</a>' . "\n"; 
  26. $out .= '</div>' . "\n"; 
  27.  
  28. $out = apply_filters('ngg_show_related_gallery_content', $out, $taglist); 
  29.  
  30. return $out;