Loading videos/etc without https

WordPress Plugins and good code samples

August 2014

function fixObjectProtocol(){

var getSrc = function(src){
return src.replace(/^(?:(ht|f)tp(s?)\:\/\/)?/i, document.location.protocol+'//');
}

// OBJECT
$('object param[name="movie"]').each(function(){
with($(this)) if(attr('value').length) attr( 'value', getSrc(attr('value')) );
});

// EMBED, HTML5
$('embed, video source, audio source').each(function(){
with($(this)) if(attr('src').length) attr( 'src', getSrc(attr('src')) );
});

}
fixObjectProtocol();

});