4

I've logged into my site in HTTPS and I'm editing on a specific post. I've dragged an image to the edit window and am now inserting an image.

The thing is WordPress is inserting the image as HTTP instead of HTTPS. It shows the URL as HTTP clearly and uneditable.

enter image description here

  1. Is there a way to change this value to HTTPS? I'm guessing no.
  2. Is there a way to tell WordPress to enter the relative URL instead of absolute URL? I'm guessing no too.

With SSL Certificates now free to any website I think this issue may come up more.

2
  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);
}
  • I do not see a site URL setting anywhere. I forgot to mention I'm using wpmu. Fwiw i checked both the network and individual site settings and did not see any place to change the site URL. – 1.21 gigawatts Dec 15 '15 at 9:48
  • 1
    yes, there is no such setting in wpmu. You can overide the defaults by usng the constants as explained here - codex.wordpress.org/Changing_The_Site_URL – Mark Kaplun Dec 15 '15 at 11:14
  • Why is using relative URLs a bad idea? If the site is on HTTP then the base URL will be HTTP:// my site. If the site is on HTTPS the base URL would be HTTPS. This would make the images show up without regard to the protocol. – 1.21 gigawatts Dec 15 '15 at 22:58
  • OK. I'll update it in the wp config file. Thanks. I would add that override suggestion to part of of your answer. – 1.21 gigawatts Dec 15 '15 at 22:59
  • relative UTRs are bad because same image might be included in two different posts and the URL of a post might change which will complicate your life if you will need to update your content every ime you do so. – Mark Kaplun Dec 16 '15 at 3:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.