2022
我们一起努力

discuz图片处理缩略图显示的方法介绍(discuz图片压缩)

php零基础到就业直播视频课:进入学习
API 文档、设计、调试、自动化测试一体化协作工具:点击使用

相关推荐:《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('forum_post')->fetch_tid_by_pid($pid);
    }
 
    if(!$tid) return array();
    $attachments = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$tid, 'pid', $pid, 'aid', 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['setting']['attachurl'].'forum/'.$attachment['attachment'];
        $thumbfile = 'image/'.helper_attach::makethumbpath($attachment['aid'], $width, $height);
        if(is_file($_G['setting']['attachdir'].$thumbfile)) {
            $thumbfile = $_G['setting']['attachurl'].$thumbfile;
        } else {
            $thumbfile = '/'.getforumimg($attachment['aid'], 0, $width, $height,'fixwr');
        }
        if($attachment['width'] < $width) $thumbfile = $bigimage;
        $list[] = array('thumb'=>$thumbfile, 'attachment'=>$bigimage, 'aid'=>$attachment['aid']);
        $count++;
        if($count >= $maximgcount) break;
    }
 
    return $list;
}

discuz图片处理缩略图显示

更多编程相关知识,请访问:www.downzz.com!!<
p>

本文从互联网转载,来源地址:www.downzz.com/discuz/208334.html,原作者保留一切权利,若侵权或引用不当,请联系茶猫云(cmy.cn)删除。【茶猫云,优质云服务器提供商】

赞(0)
文章名称:《discuz图片处理缩略图显示的方法介绍(discuz图片压缩)》
文章链接:https://www.fzvps.com/35060.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。

评论 抢沙发

评论前必须登录!