Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP to correct bad srcset attribute URLs in Scalable WordPress installs using WordPress 4.4. See http://dougv.us/r7 for details.
<?php
function azure_fix_invalid_srcset_path( $sources ) {
$storageHost = "xxx.blob.core.windows.net"; // change me to be your storage domain
$webHost = "yyy.azurewebsites.net"; // 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