Excerpt of WPENGINE's mu-plugins/wpengine-common/plugin.php file
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
/** | |
* 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