Hello,
I only serve what WordPress gives me with “wp_get_attachment_image_src” && “wp_get_attachment_image”.
If images are not getting cached I guess W3TC is not doing its work on a back-end but only on a front-end of things.
Maybe you will have to “add_filter” to replace the WP image with your CDN image.
This solution is old but you can give it a try at get back to me with the results:
http://www.alekz.net/archives/966
or
http://www.wpsuperstar.com/serving-images-from-multiple-cdns-in-wordpress/
Cheers,
David
-
This reply was modified 8 years, 8 months ago by
RosendoLabs.
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');
Hi,
Awesome! I will add this information to my FAQ.
Please dont forget to review my plugin, really appreciate it.
Cheers,
David