Yoast SEO
Switch XML Sitemap image URLs to CDN (nextgen images) (6 posts)

  1. chillmen
    Posted 3 years ago #

    I use this code to change images link in my sitemap to cdn one:
    function wpseo_cdn_filter( $uri ) {
    return str_replace( 'http://example.com', 'http://cdn.example.com', $uri );
    add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );

    It is working for post's images but not for nextgen gallery images (inside pages).
    I still have example.com instead of cdn.example.com
    Does this code work only for post's images?
    Any idea how to fix this?


  2. jimmyg164
    Posted 3 years ago #

    Hi Chillman

    where do you add add the code


  3. chillmen
    Posted 3 years ago #

    You should add this code to functions.php file (inside your theme folder)
    Here is the link to yoast website, get more infos about this code:

  4. jimmyg164
    Posted 3 years ago #

    cheers dude

  5. inquiztr
    Posted 3 years ago #

    I just noticed that my image urls in the sitemap were not pointing to my CDN. Thanks for your tip, I added the code and its fine now.

    Just curious, why is this not automated by Yoast's plugin?

  6. jimmyg164
    Posted 3 years ago #

    Hi In webmaster tools if i want to add a sitemap the only option is to add it in the root eg

    cdn.mobbly.com but my sitemap exists on the root of mobbly.com as such I have no images indexed it webmaster tools under mobbly.com

    I have added cdn.mobbly.com but can not add a sitemap

    any ideas

    kind regards

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic