discuz教程

解决同一上传图片插入多次但发布后只显示一次

discuz教程 admin 2021-01-03 人阅读

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

修改文件source/function/function_attachment.phpxy3

查找xy3

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']);
}

替换为xy3

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;
        }
}
版权声明:文章搜集于网络,如有侵权请联系本站,转载请说明出处:https://www.51yma.cn/jiaocheng/discuz/206.html
文章来源:
标签  Discuz CMS教程