nggShowRandomRecent

NggShowRandomRecent($type, $maxImages, $template, $galleryId) - return recent or random images.

Description

nggShowRandomRecent( (string) $type, (integer) $maxImages, (string) $template = '', (int) $galleryId = 0 ); 

Parameters (4)

0. $type (string)
'id' (for latest addition to DB), date (for image with the latest date), sort (for image sorted by user order) or random
1. $maximages (integer)
The maximages.
2. $template — Optional. (string) => ''
name for a template file, look for gallery-$template
3. $galleryid (int)
Limit to a specific gallery

Usage

  1. if ( !function_exists( 'nggShowRandomRecent' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextcellent-gallery/nggfunctions.php'; 
  3.  
  4. // 'id' (for latest addition to DB), 'date' (for image with the latest date), 'sort' (for image sorted by user order) or 'random' 
  5. $type = ''; 
  6.  
  7. // The maximages. 
  8. $maximages = null; 
  9.  
  10. // (optional) name for a template file, look for gallery-$template 
  11. $template = ''; 
  12.  
  13. // Limit to a specific gallery 
  14. $galleryid = -1; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = nggShowRandomRecent($type, $maximages, $template, $galleryid); 
  18.  

Defined (1)

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

/nggfunctions.php  
  1. function nggShowRandomRecent($type, $maxImages, $template = '', $galleryId = 0) { 
  2.  
  3. // $_GET from wp_query 
  4. $pid = get_query_var('pid'); 
  5. $pageid = get_query_var('pageid'); 
  6.  
  7. // get now the recent or random images 
  8. switch ($type) { 
  9. case 'random': 
  10. $picturelist = nggdb::get_random_images($maxImages, $galleryId); 
  11. break; 
  12. case 'id': 
  13. $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'id'); 
  14. break; 
  15. case 'date': 
  16. $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'date'); 
  17. break; 
  18. case 'sort': 
  19. $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'sort'); 
  20. break; 
  21. default: 
  22. // default is by pid 
  23. $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'id'); 
  24.  
  25. // look for ImageBrowser if we have a $_GET('pid') 
  26. if ( $pageid == get_the_ID() || !is_home() ) 
  27. if (!empty( $pid )) { 
  28. $out = nggCreateImageBrowser( $picturelist ); 
  29. return $out; 
  30.  
  31. // go on if not empty 
  32. if ( empty($picturelist) ) 
  33. return; 
  34.  
  35. // show gallery 
  36. if ( is_array($picturelist) ) 
  37. $out = nggCreateGallery($picturelist, false, $template); 
  38.  
  39. $out = apply_filters('ngg_show_images_content', $out, $picturelist); 
  40.  
  41. return $out;