首頁 > CMS教程 > Discuz > 主體

discuz圖片處理縮圖顯示的方法介紹

青灯夜游
發布: 2021-02-01 11:57:26
轉載
4046 人瀏覽過

discuz圖片處理縮圖顯示的方法介紹

相關推薦:《discuz教學

function thumblist($pid, $width = 0, $height = 0, $maximgcount = 3, $tid = 0){
    global $_G;
    if(!$pid) return array();
    $width = intval($width);
    $height = intval($height);
    $maximgcount = intval($maximgcount);
    $tid = intval($tid);
    $maximgcount = $maximgcount <= 0 ? 3 : $maximgcount;
    $maximgcount = min($maximgcount, 3);
    $width = $width <= 0 ? 200 : $width;
    $height = $height <= 0 ? 100 : $height;
 
    if(!$tid) {
        $tid = C::t(&#39;forum_post&#39;)->fetch_tid_by_pid($pid);
    }
 
    if(!$tid) return array();
    $attachments = C::t(&#39;forum_attachment_n&#39;)->fetch_all_by_id(&#39;tid:&#39;.$tid, &#39;pid&#39;, $pid, &#39;aid&#39;, true, false, false, $maximgcount);
    $list = array();
    $count = 0;
    $nums = count($attachments);
    if($nums ==1){
        $width = 692;
        $height =708;
    } elseif ($nums == 2) {
        $width = 660;
        $height = 700;
    } else if($nums ===3){
        $width = 440;
        $height = 532;
    }
    foreach($attachments as $aid=>$attachment) {
        $bigimage = $_G[&#39;setting&#39;][&#39;attachurl&#39;].&#39;forum/&#39;.$attachment[&#39;attachment&#39;];
        $thumbfile = &#39;image/&#39;.helper_attach::makethumbpath($attachment[&#39;aid&#39;], $width, $height);
        if(is_file($_G[&#39;setting&#39;][&#39;attachdir&#39;].$thumbfile)) {
            $thumbfile = $_G[&#39;setting&#39;][&#39;attachurl&#39;].$thumbfile;
        } else {
            $thumbfile = &#39;/&#39;.getforumimg($attachment[&#39;aid&#39;], 0, $width, $height,&#39;fixwr&#39;);
        }
        if($attachment[&#39;width&#39;] < $width) $thumbfile = $bigimage;
        $list[] = array(&#39;thumb&#39;=>$thumbfile, &#39;attachment&#39;=>$bigimage, &#39;aid&#39;=>$attachment[&#39;aid&#39;]);
        $count++;
        if($count >= $maximgcount) break;
    }
 
    return $list;
}
登入後複製

discuz圖片處理縮圖顯示

更多程式相關知識,請造訪:程式設計教學! !

以上是discuz圖片處理縮圖顯示的方法介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:csdn.net
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!