• Resolved jppinto

    (@jppinto)


    I use the following to redirect to a CDN , it works fine on WordPress images and anything in uploads on posts or pages but does not work on woocommerce images. I tried to replace “the_content” with “woocommerce_content” it did not work.

    function replace_text_wordpress($text) {
    	$text = str_replace('domain.com/wp-content/uploads/', 'domain.s3.amazonaws.com/uploads/', $text);
    	return $text;
    }
    add_filter('the_content', 'replace_text_wordpress');
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jppinto

    (@jppinto)

    I got this working by adding the same filter for woocommerce_single_product_image_thumbnail_html and woocommerce_product_get_image

    Saif

    (@babylon1999)

    Hello @jppinto,

    Glad to hear you’ve figured it out and thank you so much for the update! This will help anyone land on the thread in the future. ??

    I will go ahead and make the thread as solved, please feel free to create a new one if you have any other questions.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘URL Rewrite using str_replace’ is closed to new replies.