/** * nggShowRandomRecent($type, $maxImages, $template, $galleryId) - return recent or random images * * @access public * @param string $type 'id' (for latest addition to DB), 'date' (for image with the latest date), 'sort' (for image sorted by user order) or 'random' * @param integer $maxImages of images * @param string $template (optional) name for a template file, look for gallery-$template * @param int $galleryId Limit to a specific gallery * @return the content */ function nggShowRandomRecent($type, $maxImages, $template = '', $galleryId = 0) { // $_GET from wp_query $pid = get_query_var('pid'); $pageid = get_query_var('pageid'); // get now the recent or random images switch ($type) { case 'random': $picturelist = nggdb::get_random_images($maxImages, $galleryId); break; case 'id': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'id'); break; case 'date': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'date'); break; case 'sort': $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'sort'); break; default: // default is by pid $picturelist = nggdb::find_last_images(0, $maxImages, true, $galleryId, 'id'); } // look for ImageBrowser if we have a $_GET('pid') if ($pageid == get_the_ID() || !is_home()) { if (!empty($pid)) { $out = nggCreateImageBrowser($picturelist); 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_images_content', $out, $picturelist); return $out; }
/** * nggShowGalleryTags() - create a gallery based on the tags * * @access public * @param string $taglist list of tags as csv * @return the content */ function nggShowGalleryTags($taglist) { // $_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)) { foreach ($picturelist as $picture) { $picarray[] = $picture->pid; } $out = nggCreateImageBrowser($picarray); return $out; } } // go on if not empty if (empty($picturelist)) { return; } // show gallery if (is_array($picturelist)) { $out = nggCreateGallery($picturelist, false); } $out = apply_filters('ngg_show_gallery_tags_content', $out, $taglist); return $out; }
/** * Function to show a thumbnail or a set of thumbnails with shortcode of type: * * [thumb id="1,2,4,5,..." template="filename" /] * where * - id is one or more picture ids * - template is a name for a gallery template, which is located in themefolder/nggallery or plugins/nextgen-gallery/view * * @param array $atts * @return the_content */ function show_thumbs($atts) { extract(shortcode_atts(array('id' => '', 'template' => ''), $atts)); // make an array out of the ids $pids = explode(',', $id); // Some error checks if (count($pids) == 0) { return __('[Pictures not found]', 'nggallery'); } $picturelist = nggdb::find_images_in_list($pids); // show gallery if (is_array($picturelist)) { $out = nggCreateGallery($picturelist, false, $template); } return $out; }
/** * nggShowGalleryTags() - create a gallery based on the tags * copyright (c) Photocrati Media 2012, modified to permit a template specification * @param string $taglist list of tags as csv * @param string $template the template to use, if any * @param int $images how many images per page, defaults to all * @return string */ protected static function nggShowGalleryTags($taglist, $template, $images = false) { // $_GET from wp_query $pid = get_query_var('pid'); $pageid = get_query_var('pageid'); // record taglist and set filter to override gallery title with taglist self::$taglist = $taglist; add_filter('ngg_gallery_object', array(__CLASS__, 'nggGalleryObjectTagged')); // NextGEN Gallery 2 can show gallery of tags with template if (defined('NEXTGEN_GALLERY_PLUGIN_VERSION')) { $params = array('display_type' => 'photocrati-nextgen_basic_thumbnails', 'tag_ids' => $taglist, 'template' => $template); $registry = C_Component_Registry::get_instance(); $renderer = $registry->get_utility('I_Displayed_Gallery_Renderer'); $out = $renderer->display_images($params); } else { // get 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; } } // nothing to see, move along... if (empty($picturelist)) { return; } // show gallery if (is_array($picturelist)) { // process gallery using selected template $out = nggCreateGallery($picturelist, false, $template, $images); } } // remove filter for gallery title remove_filter('ngg_gallery_object', array(__CLASS__, 'nggGalleryObjectTagged')); $out = apply_filters('ngg_show_gallery_tags_content', $out, $taglist); return $out; }