微信论坛

 找回密码
 立即注册
查看: 16115|回复: 0
打印 上一主题 下一主题

discuz论坛帖子上传的图片调用2次以后再引用就不显示了,但编辑器里有

[复制链接]

主题

帖子

0

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
0
跳转到指定楼层
楼主
发表于 2020-11-16 15:11:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
discuz论坛帖子上传的图片调用2次以后再引用就不显示了,但编辑器里有



如题,在编辑器中上传一张图片,插入多次后编辑器里会显示多次,但发布后帖子里只显示一次。这个问题归根结底是因为代码里防灌水的设置,下面是解决方法:


修改文件source/function/function_attachment.php

查找
  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. }
复制代码


注意:修改文件之前,请先做好备份,切记。


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|微信人家论坛 ( 沪ICP备14052918号-4 )微信第三方平台沪公网安备 31011402006408号  

GMT+8, 2024-5-5 23:19 , Processed in 0.296875 second(s), 30 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表