Discuz7的图片附件不能显示的问题

一Discuz7论坛的图片附件突然无法正常显示图片,但是下载图片完全没问题。分析atachement.php这个文件,发现
dheader(‘Content-Type: ‘.$attach[‘filetype’]);出来的type都是application/oct-stream。

所以决定从这里寻找解决办法:
1、正确输出图片的Content-Type

if($type==’jpg’){
dheader(‘Content-Type: image/jpeg’);
}else if($type==’gif’){
dheader(‘Content-Type: image/gif’);
}else{
dheader(‘Content-Type: image/png’);
}
2、或者在Content-Type之前直接转向到图片位置进行显示,放弃后面对图片的读取。
$filename2=str_replace(“home/public_html/“,””,$filename);
header(‘location: ‘.$filename2);
exit();

另外如过要自定义增加图片的水印效果,可以修改getlocalfile($attachdir.’/‘.$attach[‘attachment’].’.thumb.jpg’);为

require_once DISCUZ_ROOT.’./include/image.class.php’;
$trg=$attachdir.’/‘.$attach[‘attachment’].’.thumb.jpg’;
list($img_w, $img_h) = @getimagesize($trg);
$image = new Image($trg,$trg);
$image->Thumb($thumbwidth, $thumbheight, 0);
$image->Watermark_GD_s2(1,”watermark_s.png”,$trg,$img_w, $img_h);//加水印
getlocalfile($trg);