Skip to content

Instantly share code, notes, and snippets.

@imeson
Last active January 31, 2017 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imeson/958388588653db8e2755eec062efea71 to your computer and use it in GitHub Desktop.
Save imeson/958388588653db8e2755eec062efea71 to your computer and use it in GitHub Desktop.
Excerpt of WPENGINE's mu-plugins/wpengine-common/plugin.php file
/**
* This handles CDN replacement for srcset images.
*
* @since 2.2.10
* @filter wp_calculate_image_srcset
* @param array $sources The image metadata as returned by 'wp_get_attachment_metadata()'.
*/
public function wpe_cdn_srcset( $sources ) {
if ( defined( 'WPE_SRCSET_CDN_DISABLED' ) && true === WPE_SRCSET_CDN_DISABLED ) {
return $sources;
}
foreach ( $sources as $source ) {
// The actual CDN replacement.
if ( $new_path = $this->wpe_cdn_replace( $sources[ $source['value'] ]['url'] ) ) {
$sources[ $source['value'] ]['url'] = $new_path;
}
}
return $sources;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment