Hi all,
I have a simple function (in function.php) that replaces the image hostname to speedup page loading:
function cdn_images() {
$content = ob_get_contents();
$pattern = '/src=[\\"\']?([^\\"\']?.*(png))[\\"\']?/i';
preg_match_all( $pattern, $content, $matches );
foreach($matches[1] as $val) {
$test = str_replace('www.domain.com', 'images.domain.com', $val);
echo $test.'<br />';
}
}
When placed on footer this obviously works well giving me new image paths. What I would like to do is to replace these images on the fly via WP hook.
Anyone knows how to do this?
Thanks!