[Fixed] Images are not Loading in CDN URL format in Yoast SEO Sitemap


Images are not Loading in CDN URL format

Images are not Loading in CDN URL format

[Fixed] Images are not Loading in CDN URL format in Yoast SEO Sitemap

yesterday we Migrated our WordPress website to new hosting and add HTTPS (SSL) to our website today Morning I Check our website whether all are in HTTPS format at that time I open the Yoast SEO sitemap.

And open the post sitemap XML and check the view source and I found the issue Images are not loading in CDN URL we are using KEYCDN for our website I purge the cache from my KEYCDN dashboard but no good result.

Images are not Loading in CDN URL format

After that I searching a solution for this I got a PHP Snippets for fix this issue

Just follow My below steps to Fix the Images are not Loading in CDN URL format in Yoast SEO Sitemap

  • Open your themes functions.php file
  • Now copy the Below code on your theme’s functions.php file
function wpseo_cdn_filter( $uri ) {
 return str_replace( 'http://www.yourwebsitename.com', 'http://cdn.yourwebsitename.com', $uri );
 }
 add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );
  • replace http://www.yourwebsitename.com with your website URL and
  • replace http://cdn.yourwebsitename.com with your Custom CDN URL
  • Now open your post XML sitemap and check view source check the below image

Images are not Loading in CDN URL format

  • Tha’s all successfully we fix the Images are not Loading in CDN URL format in Yoast SEO Sitemap

Special thanks to Yoast team I got this code from the Yoast official website

If you have Any Doubts in this topic, Please feel free to comment here.

Try – Google Analytics Post Survey widget 

 



Was this article helpful?
Thanks!

Your feedback helps us improve Allwebtuts.com