當前位置: 首頁>>代碼示例>>PHP>>正文


PHP nggdb::get_random_images方法代碼示例

本文整理匯總了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;
}
開發者ID:popovdenis,項目名稱:kmst,代碼行數:51,代碼來源:nggfunctions.php

示例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
開發者ID:pravinhirmukhe,項目名稱:flow1,代碼行數:31,代碼來源:foto.php


注:本文中的nggdb::get_random_images方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。