Skip to content

Instantly share code, notes, and snippets.

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 with whatever is your site's domain.
* 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( '', '', $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