I have a site with FORCE_SSL_ADMIN turned on. When I'm editing a post with an embedded image, or when I'm viewing images through the media library, they are loaded using the http:// protocol rather than https. This causes a mixed-content warning in IE, which clients kind of freak out about.

Does anyone have a recommended approach for finding/replacing these non-secure image URLs while viewing them through the admin?

The frontend loads over regular http, so I don't want to do any replacing in the DB that will force images to load over https outside of the admin.

I figure this has to be a common problem, so I'd appreciate any advice, even if it's "you can't do that".


2 Answers 2


You can't right now. This needs to be fixed in wordpress core. Probably this can be temporarily circumvented for a fraction of the problems with a plugin, but it's much more valuable to invest the time developing something in an actual fix of wordpress.

  • Thanks @hakre. I checked trac, and coincidentally it looks like someone filed the underlying issue a couple days ago (core.trac.wordpress.org/ticket/15928). Hopefully it'll be worked into a coming release! I find it a bit weird that more people haven't had this problem though... maybe SSL administration isn't as widely used as I assumed.
    – MathSmath
    Dec 23, 2010 at 6:33

Thankfully the fix for core.trac.wordpress.org/ticket/15928 is scheduled to be included in the next release. Until then, you can use the following code as a work-around. ( Props to Andrew Tetlaw for the fix. )

Add it to your theme's functions.php file, or put in a file (i.e. fix_ssl.php ) and place it in your wp-content/mu-plugins folder.

function fix_ssl_siteurl($url) {
  if ( 0 === strpos($url, 'http') && is_ssl() )
    $url = str_replace( 'http://', 'https://', $url );
  return $url;
add_filter('option_siteurl', 'fix_ssl_siteurl');
add_filter('option_home', 'fix_ssl_siteurl');
add_filter('option_url', 'fix_ssl_siteurl');
add_filter('option_wpurl', 'fix_ssl_siteurl');
add_filter('option_stylesheet_url', 'fix_ssl_siteurl');
add_filter('option_template_url', 'fix_ssl_siteurl');
  • Unfortunately the ticket mentioned didn't get into 3.3 after all. I'll be pushing for 3.4
    – marfarma
    Dec 22, 2011 at 22:12
  • Still an issue as of WP 4.1. Ticket was active toward end of release cycle but didn't make it in.
    – mrwweb
    Jan 9, 2015 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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