Skip to content

Instantly share code, notes, and snippets.

@gyrus
Created April 16, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gyrus/8b9105f062513bf24f1b to your computer and use it in GitHub Desktop.
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
<?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