Skip to content

Instantly share code, notes, and snippets.

@imeson

imeson/plugin.php

Last active Jan 31, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.