Niels Lynx - 2007-08-17 22:03:14
First of all, thank you for this great class.
I had use the rewrite src path i noticed it didnt support the css background imgs, so i coded it.
I hope this can be usefull to someone
Here's the new function (the old one is @ around line 550):
function rewrite_src_path($contents){
// Rewrite src path regex using Heredoc
$regexPattern[] = "/src\s*=(.*?)[\\\"']?([^\\\"' >]+)[\\\"'> ]/is";//src="..."
$regexReplacement[] = 'src="'.$this->REWRITE_SRC_PATH.'\\2"';
//added by Niels Bugge
$regexPattern[] = "/(background:.*)\s?url\s*\((.*)\)([^;]*;)/siU";//style="background:url(...);"
$regexReplacement[] = '\\1 url('.$this->REWRITE_SRC_PATH.'\\2)\\3';
//$regexPattern[] = "/<\s*link\s+[^>]*href\s*=\s*[\\\"']?([^\\\"' >]+)[\\\"' >]/is"; //BUG in 1.5.1
$regexPattern_2 = "/<\s*link\s+[^>]*href\s*=\s*[\\\"']?[^\\\"' >]+[\\\"' >]/is";
if(sizeof($this->REWRITE_SRC_PATH)>0) {
$contents=preg_replace($regexPattern, $regexReplacement, $contents);
// preg_reclace_callback return his result to a function outside class body
$GLOBALS['REWRITE_SRC_PATH'] = $this->REWRITE_SRC_PATH;
$contents=preg_replace_callback($regexPattern_2, 'rewrite_link_href_callback', $contents);
unset($GLOBALS['REWRITE_SRC_PATH']);
}
return $contents;
}
I Hope i help someone.
good night :)