本文整理汇总了PHP中nggdb::get_random_images方法的典型用法代码示例。如果您正苦于以下问题:PHP nggdb::get_random_images方法的具体用法?PHP nggdb::get_random_images怎么用?PHP nggdb::get_random_images使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nggdb
的用法示例。
在下文中一共展示了nggdb::get_random_images方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nggShowRandomRecent
/**
* 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;
}
示例2: header
<?php
require_once './wp-content/plugins/nextgen-gallery/ngg-config.php';
require_once './inc/php/cfg.php';
if (!empty($_GET['pid'])) {
$foto = nggdb::find_image($_GET['pid']);
if (empty($foto) or $foto->exclude == 1) {
$fotos = nggdb::get_random_images();
$foto = $fotos[0];
}
$tags = wp_get_object_terms($_GET['pid'], 'ngg_tag');
} else {
if ($_SESSION['last_pid'] > 0) {
$pid = mt_rand(1, $_SESSION['last_pid']);
header("Location: /foto/{$pid}.html");
} else {
header('Location: /');
}
}
$foto_url = str_replace($cfg['trueurl'], $cfg['baseurl'], $foto->imageURL);
//输出页头keywords
if (!empty($tags)) {
$key_arr = array();
foreach ($tags as $tag) {
$key_arr[] = $tag->slug;
$keywords = implode(',', $key_arr);
}
} else {
$keywords = $cfg['keywords'];
}
//输出keywords