首页 > CMS教程 > Discuz    日期:2020-02-19 / 来自互联网 / 浏览

在编辑器中上传一张图片,插入多次后编辑器里会显示多次,但发布后帖子里只显示一次

修改文件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[0] as $key => $value){
                $tempattach = $postlist[$pid]['attachments'][$aid]['aid'];
               if(count($sameattach[0]) > 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;
        }
}

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章