Discuz!图片附件获取缩略图路径makethumbpath以及生成缩略图方法

159 篇文章 3 订阅
144 篇文章 1 订阅

定义文件:

\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'];



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值