Thread Starter
bikkun
(@bikkun)
That works, thanks!
Here is the fixed I used, had to hard code the types and cdn url because w3total stores its config in a text file.
function cdn_image_url($url)
{
$types = ["gif", "png", "jpg"];
$type = substr($url, -3);
if(in_array($type, $types)) {
$site = get_site_url();
$cdn = "{Insert cdn url here}";
$url = str_replace($site, $cdn, $url);
}
return $url;
}
add_filter ('wp_get_attachment_url', 'cdn_image_url');