[Discuz] 解决编辑器图片插入多次但发布后只显示一次问题

2023-03-19 | 133 人阅读

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

需要修改的文件:source/function/function_attachment.php
查找以下代码一般在166~169行:

  1. foreach($findattach[$pid] as $aid => $find) {
  2.        $postlist[$pid]['message'] = preg_replace($find, attachinpost($postlist[$pid]['attachments'][$aid], $postlist[$pid]), $postlist[$pid]['message'], 1);
  3.        $postlist[$pid]['message'] = preg_replace($find, '', $postlist[$pid]['message']);
  4. }
复制代码
替换成:
  1. foreach($findattach[$pid] as $aid => $find) {
  2.          //$postlist[$pid]['message'] = preg_replace($find, attachinpost($postlist[$pid]['attachments'][$aid], $postlist[$pid]), $postlist[$pid]['message'], 1);
  3.         //$postlist[$pid]['message'] = preg_replace($find, '', $postlist[$pid]['message']);

  4.         preg_match_all($find, $postlist[$pid]['message'], $sameattach);
  5.         foreach($sameattach[0] as $key => $value){
  6.                 $tempattach = $postlist[$pid]['attachments'][$aid]['aid'];
  7.                if(count($sameattach[0]) > 1 && $key > 0) {
  8.                           $postlist[$pid]['attachments'][$aid]['aid'] = $postlist[$pid]['attachments'][$aid]['aid'].'_'.$key;
  9.                           $GLOBALS['aimgs'][$pid][] = $postlist[$pid]['attachments'][$aid]['aid'];
  10.                }
  11.                $postlist[$pid]['message'] = preg_replace($find, attachinpost($postlist[$pid]['attachments'][$aid], $postlist[$pid]), $postlist[$pid]['message'], 1);
  12.                $postlist[$pid]['attachments'][$aid]['aid'] = $tempattach;
  13.         }
  14. }
复制代码
通过以上方法我们可以多次凋用同一张图片在不同的地方,比如一些常用的分割线。

[occ]文档来源:网络转载 https://www.dismall.com/thread-2233-1-1.html[/occ]
关注下面的标签,发现更多相似文章
112984 积分
917 主题
热门推荐