Skip to content

Instantly share code, notes, and snippets.

@theJasonJones
Created April 5, 2016 15:41
Show Gist options
  • Save theJasonJones/5f1953c429598f2863cd187e4b43c166 to your computer and use it in GitHub Desktop.
Save theJasonJones/5f1953c429598f2863cd187e4b43c166 to your computer and use it in GitHub Desktop.
Force URLs in srcset attributes into HTTPS scheme. A.K.A Fix for WP 4.4 responsive images.
/*
* Force URLs in srcset attributes into HTTPS scheme.
*/
function ssl_srcset( $sources ) {
foreach ( $sources as &$src ) {
$src['url'] = set_url_scheme( $src['url'], 'https' );
}
return $sources;
}
add_filter( 'wp_calculate_image_srcset', 'ssl_srcset' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment