首頁 > CMS教程 > Discuz > discuz圖片處理縮圖顯示的方法介紹

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

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

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

相關推薦:《discuz教學

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

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中文網其他相關文章!

相關標籤:
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
phpStudy怎麼安裝discuz
來自於 1970-01-01 08:00:00
0
0
0
php - discuz 單一登入問題
來自於 1970-01-01 08:00:00
0
0
0
php - Dedecms系統與discuz系統的問題
來自於 1970-01-01 08:00:00
0
0
0
phpStudy—Apache+PHP5.2.17本機架設Discuz!論壇
來自於 1970-01-01 08:00:00
0
0
0
nginx設定discuz二級網域的問題
來自於 1970-01-01 08:00:00
0
0
0
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板