2014-10-30 92 views
2

Smarty的輸出過濾器替換smarty模板中的圖像URL與您的cdn url e。圖像,如:Smarty cdn輸出過濾器的圖像

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

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

請嘗試進一步解釋你的問題和你的過程是讓你的Web服務器上的文件。 – NobleUplift 2014-10-30 20:40:48

回答

1

我覺得有這樣的

<?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; } ?>