Smarty的输出过滤器,它将Smarty模板中的图像URL替换为您的CDN URL
例如,像这样的图像:
<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; } ?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句