一个资源分享、信息整合的综合性站点。

标题: 织梦dedecms远程图片本地化https链接图片无法本地化怎么解决? [打印本页]

作者: 树苗收集系    时间: 2019-11-23 21:17
标题: 织梦dedecms远程图片本地化https链接图片无法本地化怎么解决?
最近有朋友遇到发布文章时候文章里面带https的站外图片无法本地化,以下是解决办法:

找到  dede//inc/inc_archives_functions.php文件里面GetCurContent($body)这个函数,里面
  1. preg_match_all("/src=["|'|s]{0,}(http://([^>]*).(gif|jpg|png))/isU",$body,$img_array);
  2. $img_array = array_unique($img_array[1]);
复制代码
这一段改为:
  1. preg_match_all("/src=["|'|s]{0,}(http://([^>]*).(gif|jpg|png))/isU",$body,$img_array);
  2. preg_match_all("/src=["|'|s]{0,}(https://([^>]*).(gif|jpg|png))/isU",$body,$img_array_https);
  3. $img_array = array_unique($img_array[1]);
  4. $img_array_https = array_unique($img_array_https[1]);
  5. $img_array=array_merge_recursive($img_array,$img_array_https);
复制代码
第二步:
  1. if(!preg_match("#^http://#i", $value))
  2. {
  3. continue;
  4. }
复制代码

这一段改为:

  1. if(!preg_match("#^http://#i", $value)&&!preg_match("#^https://#i", $value))
  2. {
  3. continue;
  4. }
复制代码

搞定,这样发文章就可以把https的远程图片也本地化了







欢迎光临 一个资源分享、信息整合的综合性站点。 (https://www.sorv.cn/) Powered by Discuz! X3.4