I am trying to setup CDN on woocommerce theme. Here's what I have added to the functions.php

add_filter( 'woocommerce_single_product_image_html', 'replace_content' );
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'replace_content' );
add_filter( 'woocommerce_product_thumbnails', 'replace_content' );

The above code works fine on single product page but not on woocommerce widgets and shop page.

How can I use add_filter to apply the CDN url to all images loaded by woocommerce?

1 Answer 1


You could just use a plugin such as CDN Enabler which will change the URL of all your static files to point to the CDN URL. This works for all your images, CSS/JS files, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.