Created
December 11, 2015 03:23
-
-
Save joemcgill/9b1b597b9f1907772b0a to your computer and use it in GitHub Desktop.
Force WordPress `srcset` to HTTPS
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
/* | |
* Force URLs in srcset attributes into HTTPS scheme. | |
* This is particularly useful when you're running a Flexible SSL frontend like Cloudflare | |
*/ | |
function ssl_srcset( $sources ) { | |
foreach ( $sources as &$source ) { | |
$source['url'] = set_url_scheme( $source['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