Discuz論壇教程之圖片附件獲取縮略圖路徑makethumbpath以及生成縮略圖方法,對使用discuz論壇的愛好者是一個福音,你在用嗎,如果在用的話,趕緊來看看下面的這些教程吧!
定義文件:
/source/class/helper/helper_attach.php
方法定義:
public static function makethumbpath($id, $w, $h){
$dw = intval($w);
$dh = intval($h);
$_daid = sprintf("%09d", $id);
$dir1 = substr($_daid, 0, 3);
$dir2 = substr($_daid, 3, 2);
$dir3 = substr($_daid, 5, 2);
return $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($_daid, -2).'_'.$dw.'_'.$dh.'.jpg';
}
參數說明:
$id:附件aid
$w:縮略圖寬度
$h:縮略圖高度
使用方法:
$path=helper_attach::makethumbpath($aid, $width,$height);
完整路徑:
'/data/attachment/image/'.$path;
縮略圖生成方法:
require_once libfile('class/image');
$img = new image;
$img->Thumb($filename, $path, $w, $h, $type);
其中$filename為改附件圖片的原始路徑
$filename = $_G['setting']['attachdir'].'forum/'.$attach['attachment'];
新聞熱點
疑難解答