帝国cms远程图片本地化不生效!有哪些原因?

2022-01-1423:06:30网站建设与开发Comments1,829 views字数 1405阅读模式

帝国cms远程图片本地化是一个非常重要的功能,即使不用采集日常更新也经常用得着,我们有时候会发现这个功能不生效,常见有哪些不生效的原因呢文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

帝国cms远程图片本地化不生效原因文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

1、图片格式和大小设置问题文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

帝国默认的图片格式不包括png,但是我们现在qq截图等都是png图片格式,加进去即可,假如源站的图片格式帝国后台没有,那肯定保存不了了。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

系统参数设置——文件设置——文件扩展名文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

同时设置可以上传图片大小。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

2、服务器配置问题文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

需要在php.in中把allow_url_fopen设置为on文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

3、入库超时502问题文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

这个在图片数量特别多的时候可能出现,把php执行时间设置长一点,一般默认60s,改成几分钟即可文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

4、源站图片链接是https文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

这个是现在遇到比较多的一个问题,目前7.5版本是不支持采集https图片的,需要增加ssl模块支持文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

打开文件/e/class/connect.php:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

第一步:在connect.php文件最上面,<?php下面添加以下函数:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

  1. function getHTTPS($url) {
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  4. curl_setopt($ch, CURLOPT_HEADER, false);
  5. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  6. curl_setopt($ch, CURLOPT_URL, $url);
  7. curl_setopt($ch, CURLOPT_REFERER, $url);
  8. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  9. $result = curl_exec($ch);
  10. curl_close($ch);
  11. return $result;
  12. }

 文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

第二步:搜索function ReadFiletext,找到以下函数:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

  1. function ReadFiletext($filepath){
  2. $filepath=trim($filepath);
  3. $htmlfp=@fopen($filepath,"r");
  4. //远程
  5. if(strstr($filepath,"://"))
  6. {
  7. while($data=@fread($htmlfp,500000))
  8. {
  9. $string.=$data;
  10. }
  11. }
  12. //本地
  13. else
  14. {
  15. $string=@fread($htmlfp,@filesize($filepath));
  16. }
  17. @fclose($htmlfp);
  18. return $string;
  19. }

换成以下代码:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

  1. function ReadFiletext($filepath){
  2. $filepath=trim($filepath);
  3. $htmlfp=@fopen($filepath,"r");
  4. //远程
  5. if(strstr($filepath,"https://")){
  6. return getHTTPS($filepath);
  7. }
  8. if(strstr($filepath,"://"))
  9. {
  10. while($data=@fread($htmlfp,500000))
  11. {
  12. $string.=$data;
  13. }
  14. }
  15. //本地
  16. else
  17. {
  18. $string=@fread($htmlfp,@filesize($filepath));
  19. }
  20. @fclose($htmlfp);
  21. return $string;
  22. }

以上就是常见的帝国cms远程图片保存失败的原因。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/22864.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/cms/22864.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定