一、首先修改图片大小
因为dz的图片分为好几种上传形式,有从相册上传,有网络图片,有图片附件,
但我的理解,总体其实就是分为:附件图片和网络图片两种形式
A、 先说网络图片大小的修改
在function_viewthread.php 中,找到
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $_G['forum']['allowbbcode'], ($_G['forum']['allowimgcode'] && $_G['setting']['showimages'] ? 1 : 0), $_G['forum']['allowhtml'], ($_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0), 0, $post['authorid'], $_G['forum']['allowmediacode'], $post['pid']);
在它的前面添加:
$aa = "/\[img\=[0-9]+\,[0-9]+\]/";
$bb = "[img]";
$cc = "[img=80,0]";
$post['message'] = preg_replace($aa, $bb, $post['message']);
$post['message'] = str_replace($bb, $cc, $post['message']);
B、附件图片大小修改
在function_attachment文件中,找到
function attachwidth($width) {
global $_G;
if($_G['setting']['imagemaxwidth'] && $width) {
return 'width="'.($width > $_G['setting']['imagemaxwidth'] ? $_G['setting']['imagemaxwidth'].(!defined('IN_MOBILE') ? '" class="zoom"': '') : $width.'"');
} else {
return 'thumbImg="1"';
}
}
我的理解是,它返回了附件图片的宽度,以及等比例缩放,所以,在这可以对图片大小进行限定,返回一个固定值
我是这么写的:
function attachwidth($width) {
global $_G;
//有修改 20110913 限定未登录时,附件图片的显示大小
if(!$_G['uid']){
return 'width=80';
}
if($_G['setting']['imagemaxwidth'] && $width) {
return 'width="'.($width > $_G['setting']['imagemaxwidth'] ? $_G['setting']['imagemaxwidth'].(!defined('IN_MOBILE') ? '" class="zoom"': '') : $width.'"');
} else {
return 'thumbImg="1"';
}
}
|