Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Smarty cdn图像输出过滤器_Php_Image_Url_Smarty - Fatal编程技术网

Php Smarty cdn图像输出过滤器

Php Smarty cdn图像输出过滤器,php,image,url,smarty,Php,Image,Url,Smarty,smarty的输出筛选器,它将smarty模板中的图像URL替换为您的cdn URL e、 g.像这样的图像: <img src="/images/image.gif"/> <img src="http://cdn.yoursite.com/images/image.gif"/> 我想是这样的 <?php function smarty_outputfilter_cdn($tpl_source, &$smarty

smarty的输出筛选器,它将smarty模板中的图像URL替换为您的cdn URL

e、 g.像这样的图像:

<img src="/images/image.gif"/>

<img src="http://cdn.yoursite.com/images/image.gif"/>

我想是这样的

<?php  function smarty_outputfilter_cdn($tpl_source, &$smarty)  {      if($_SERVER["SERVER_PORT"] == 80) {          $tpl_source = preg_replace('/("|\')((\.\/|\/)[A-z0-9_\-\/@\.]+\.(jpg|jpeg|gif|png))("|\')/i', "\"http://cdn.yoursite.com\\2\"", $tpl_source);      }            return $tpl_source;  }  ?>

请尝试进一步解释您的问题以及在web服务器上获取此文件的过程。