Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.