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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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