WordPress is Inserting images into Post as HTTP and not HTTPS

  1. Change the site URL to be HTTPS based instead of HTTP. In other words go fully HTTPS on your site. If you need mixed content solution for serving your HTML both as HTTP and HTTPS you will need some dynamic detection and manipulation of URLs in the contents or serve as protocol neutral url.

  2. very bad idea. The best you can get is protocol neutral Urls.

You can try something like

add_filter('the_content','wpse_211864',1000,1);

// remove 'http:' part from any mention of the site url
function wpse_211864($content) {
    return str_replace(siteurl(),str_replace('http:','',siteurl()),$content);
}

Leave a Comment