Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Last active October 9, 2018 05:28
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Snippet to replace image URIs with CDN image URIs in the XML sitemaps generated by WordPress SEO by Yoast. Obviously replace yoast.com with whatever is your site's domain.
<?php
/**
* Replace image URIs with CDN image URIs
*
* @param string $uri
*
* @return string
*/
function yst_cdn_filter( $uri ) {
if ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
return $uri;
}
return str_replace( 'https://yoast.com', 'https://cdn.yoast.com', $uri );
}
add_filter( 'wpseo_xml_sitemap_img_src', 'yst_cdn_filter' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment