Thursday, 15 April 2010

php - Smarty cdn output filter for images -



php - Smarty cdn output filter for images -

output filter smarty wich replaces image url within smarty templates cdn url e. image like:

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

i think there's

<?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); } homecoming $tpl_source; } ?>

php image url smarty

No comments:

Post a Comment