Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHP to correct bad srcset attribute URLs in Scalable WordPress installs using WordPress 4.4. See for details.
function azure_fix_invalid_srcset_path( $sources ) {
$storageHost = ""; // change me to be your storage domain
$webHost = ""; // change this to be your website domain
$container = "wp-media"; // change this to be the name of your storage container
$newpath = str_replace( $webHost, $storageHost, $sources['url'] );
return str_replace( "wp-content/uploads/D:homesitewwwroot/wp-content/uploads", $container, $newpath );
add_filter( 'wp_calculate_image_srcset', 'azure_fix_invalid_srcset_path' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment