Created
April 16, 2015 23:59
-
-
Save gyrus/8b9105f062513bf24f1b to your computer and use it in GitHub Desktop.
Filter images sent to editor to make the URLs protocol-relative for possible SSL
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
<?php | |
add_filter( 'image_send_to_editor', 'pilau_protocol_relative_image_urls', 999999 ); | |
/** | |
* Filter images sent to editor to make the URLs protocol-relative for possible SSL | |
*/ | |
function pilau_protocol_relative_image_urls( $html ) { | |
// Replace protocols with relative schema | |
$html = str_replace( array( 'http://', 'https://' ), '//', $html ); | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment