discuz论坛帖子上传的图片调用2次以后再引用就不显示了,但编辑器里有
discuz论坛帖子上传的图片调用2次以后再引用就不显示了,但编辑器里有如题,在编辑器中上传一张图片,插入多次后编辑器里会显示多次,但发布后帖子里只显示一次。这个问题归根结底是因为代码里防灌水的设置,下面是解决方法:
修改文件source/function/function_attachment.php
查找
foreach($findattach[$pid] as $aid => $find) {
$postlist[$pid]['message'] = preg_replace($find, attachinpost($postlist[$pid]['attachments'][$aid], $postlist[$pid]), $postlist[$pid]['message'], 1);
$postlist[$pid]['message'] = preg_replace($find, '', $postlist[$pid]['message']);
}
替换为
foreach($findattach[$pid] as $aid => $find) {
//$postlist[$pid]['message'] = preg_replace($find, attachinpost($postlist[$pid]['attachments'][$aid], $postlist[$pid]), $postlist[$pid]['message'], 1);
//$postlist[$pid]['message'] = preg_replace($find, '', $postlist[$pid]['message']);
preg_match_all($find, $postlist[$pid]['message'], $sameattach);
foreach($sameattach as $key => $value){
$tempattach = $postlist[$pid]['attachments'][$aid]['aid'];
if(count($sameattach) > 1 && $key > 0) {
$postlist[$pid]['attachments'][$aid]['aid'] = $postlist[$pid]['attachments'][$aid]['aid'].'_'.$key;
$GLOBALS['aimgs'][$pid][] = $postlist[$pid]['attachments'][$aid]['aid'];
}
$postlist[$pid]['message'] = preg_replace($find, attachinpost($postlist[$pid]['attachments'][$aid], $postlist[$pid]), $postlist[$pid]['message'], 1);
$postlist[$pid]['attachments'][$aid]['aid'] = $tempattach;
}
}
注意:修改文件之前,请先做好备份,切记。
页:
[1]