Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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".

share|improve this question
    
Please report the issue on wordpress trac: core.trac.wordpress.org –  hakre Dec 22 '10 at 22:07
add comment

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
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 '10 at 6:33
add comment

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');
share|improve this answer
    
Unfortunately the ticket mentioned didn't get into 3.3 after all. I'll be pushing for 3.4 –  marfarma Dec 22 '11 at 22:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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