From a444028be3f5bc4615721562e682ce54771fabfc Mon Sep 17 00:00:00 2001 From: Devil Date: Thu, 25 Mar 2021 01:22:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=98=E8=B4=B4=E6=95=B0=E6=8D=AE=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=AB=99=E7=82=B9=E5=9B=BE=E7=89=87=E4=B8=8D=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/service/UeditorService.php | 50 ++++++++++++++------------ 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/application/service/UeditorService.php b/application/service/UeditorService.php index 9a31d1925..addf04b05 100644 --- a/application/service/UeditorService.php +++ b/application/service/UeditorService.php @@ -274,34 +274,40 @@ class UeditorService ); $field_name = self::$current_config['catcherFieldName']; - /* 抓取远程图片 */ + // 当前站点域名或者附件域名不下载 + $cdn_attachment_host = MyFileConfig('common_cdn_attachment_host', '', __MY_PUBLIC_URL__, true); + + // 抓取远程图片 $list = array(); $source = isset(self::$params[$field_name]) ? self::$params[$field_name] : self::$params[$field_name]; foreach($source as $imgUrl) { - $up = new \base\Uploader($imgUrl, $temp_config, "remote"); - /** - * 得到上传文件所对应的各个参数,数组结构 - * array( - * "state" => "", //上传状态,上传成功时必须返回"SUCCESS" - * "url" => "", //返回的地址 - * "path" => "", //绝对地址 - * "title" => "", //新文件名 - * "original" => "", //原始文件名 - * "type" => "" //文件类型 - * "size" => "", //文件大小 - * "hash" => "", //sha256值 - * ) - */ - $data = $up->getFileInfo(); - if(isset($data['state']) && $data['state'] == 'SUCCESS') + if(GetUrlHost($imgUrl) != $cdn_attachment_host) { - $data['type'] = 'image'; - $data['path_type'] = self::$path_type; - $ret = ResourcesService::AttachmentAdd($data); - if($ret['code'] == 0) + $up = new \base\Uploader($imgUrl, $temp_config, "remote"); + /** + * 得到上传文件所对应的各个参数,数组结构 + * array( + * "state" => "", //上传状态,上传成功时必须返回"SUCCESS" + * "url" => "", //返回的地址 + * "path" => "", //绝对地址 + * "title" => "", //新文件名 + * "original" => "", //原始文件名 + * "type" => "" //文件类型 + * "size" => "", //文件大小 + * "hash" => "", //sha256值 + * ) + */ + $data = $up->getFileInfo(); + if(isset($data['state']) && $data['state'] == 'SUCCESS') { - array_push($list, $ret['data']); + $data['type'] = 'image'; + $data['path_type'] = self::$path_type; + $ret = ResourcesService::AttachmentAdd($data); + if($ret['code'] == 0) + { + array_push($list, $ret['data']); + } } } }