织梦DEDECMS远程图片遇到https无法本地化的解决

网站建设 2022-07-27 09:12www.1681989.com免费网站
对于http的远程图片本地化,dedecms能很好解决,碰到https的就无法本地化了,推火网以下是解决办法 找到 dede//c/c_archives_functions.php文件里面GetCurContent($body)这个函数,里面 1 preg_match […]



对于http的远程图片本地化,dedecms能很好解决,碰到https的就无法本地化了,推火网以下是解决办法

找到 dede//c/c_archives_functions.php文件里面GetCurContent($body)这个函数,里面
 

1 preg_match_all(“/src=[\”|’|\s]{0,}(http:\/\/([^>])\.(gif|jpg|png|jpeg|bmp))/isU”,$body,$img_array);
2  
3 $img_array = array_unique($img_array[1]);


这一段改为
 

1 preg_match_all(“/src=[\”|’|\s]{0,}(http:\/\/([^>])\.(gif|jpg|png|jpeg|bmp))/isU”,$body,$img_array);
2  
3 preg_match_all(“/src=[\”|’|\s]{0,}(https:\/\/([^>])\.(gif|jpg|png|jpeg|bmp))/isU”,$body,$img_array_https);
4  
5 $img_array = array_unique($img_array[1]); $img_array_https = array_unique($img_array_https[1]); $img_array=array_merge_recursive($img_array,$img_array_https);
 

第二步
 

1 if(!preg_match(“#^http:\/\/#i”, $value))
2 {
3 contue;
4 }


这一段改为
 

查看源码
 
打印代码帮助
1 if(!preg_match(“#^http:\/\/#i”, $value)&&!preg_match(“#^https:\/\/#i”, $value))
2 {
3 contue;
4 }



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


Copyright © 2016-2025 www.1681989.com 推火网 版权所有 Power by