• Hi,

    Since version 4.2 or maybe 4.2.1, when I insert a media in a post when I’m connected to the admin through HTTPS, the editor inserts the media with HTTPS link (img src and a href).
    As I’m using a self-signed SSL certificate and most of my visitors are using HTTP without SSL, this is an annoying behavior, as I have to manually edit each link… If I leave HTTPS links, the images are not displayed when the visitor is using HTTP (self signed certificate is rejected without warning).
    Is there a way to prevent the editor to insert HTTPS links ? For now, the only workarounds I found is manually changing the links or connecting to the admin without through HTTP.

Viewing 1 replies (of 1 total)
  • Thread Starter Matthieu S

    (@sartmatt)

    Finally found a workaround, by replacing the scheme when displaying the post for all the URL referring to the site’s host in any src or href attribute by putting this in an mu-plugin :

    function forceContentURLScheme($content) {
    $host = $_SERVER[“HTTP_HOST”];
    $newScheme = “http”;
    $oldScheme = “https”;
    if (is_ssl()) {
    $newScheme = “https”;
    $oldScheme = “http”;
    }
    return preg_replace(“#(src|href)=\”$oldScheme://$host#”, “\\1=\”$newScheme://$host”, $content);
    }
    add_filter(“the_content”, “forceContentURLScheme”);

    Not the cleanest solution, but it seems to work…

Viewing 1 replies (of 1 total)
  • The topic ‘Disable HTTPS in media link ?’ is closed to new replies.