Relative Image URLs
Will it remove SSL request? (5 posts)

  1. Enterpr1se
    Posted 3 years ago #


    I am using HTTPS Force SSL Administration in my site.
    When I add images, it will show https://domain.com/wp-contant/uploads/

    I found that this plugin just remove the http request part in small image
    when I insert a image, it will like this
    <img class="aligncenter size-medium wp-image-11604" alt="StartrekWallpaper" src="//domain.com/wp-content/uploads/2013/05/StartrekWallpaper-640x383.jpg" width="640" height="383" />

    Is there any setting to let it full relative URLs?


  2. Scott Werner
    Plugin Author

    Posted 3 years ago #

    When you insert an image, the url should appear as this:

    I'm not 100% sure on your question. Do you want it to remove the //domain.com part?

  3. rhertzog
    Posted 3 years ago #

    I have the exact same problem... as he said, the initial URL submitted by the media browser starts with https:// because we're using SSL to protect the administrative area (everything in /wp-admin/).

    So you need to strip https:// in addition to http://

    Replace str_replace("http://","",$imageurl); with preg_replace("/^https?:\/\//","",$imageurl);

    In fact this is my use case for this plugin. I don't want to hardcode https:// in URL because I want visitors to load the pictures with the same protocol that they used to load the page that they are visiting. My SSL certificate is self-signed and browsers won't load pictures from self-signed https servers when they are visiting a non-https page.

  4. rhertzog
    Posted 3 years ago #

    Just to be clear, obviously the part "//domain.com" is completely wrong in the URL that he gets. It's the hostname of the original URL and it shouldn't end up in the relative URL.

    Also the plugin doesn't work when the URL of the link is different from the URL of the displayed image (quite a common case):

    I get this for instance:
    <a href="https://badminton-sorbiers.fr/files/2013/07/photo-bad.jpg"><img src="/files/2013/07/photo-bad-174x300.jpg" alt="photo bad" width="174" height="300" class="aligncenter size-medium wp-image-1064" /></a>

    instead of the expected

    <a href="/files/2013/07/photo-bad.jpg"><img src="/files/2013/07/photo-bad-174x300.jpg" alt="photo bad" width="174" height="300" class="aligncenter size-medium wp-image-1064" /></a>

    So maybe you need to also take care of the replacing what you find in the href attribute...

  5. Enterpr1se
    Posted 3 years ago #


    The output is

    <a href="https://www.enterpr1se.info/wp-content/uploads/2013/05/Yahoo_HK_Enterpr1se.png"><img class="aligncenter size-medium wp-image-12255" alt="Yahoo_HK_Enterpr1se" src="//www.enterpr1se.info/wp-content/uploads/2013/05/Yahoo_HK_Enterpr1se-640x305.png" width="640" height="305" /></a>

    I expect the result should be

    <a href="/wp-content/uploads/2013/05/Yahoo_HK_Enterpr1se.png"><img class="aligncenter size-medium wp-image-12255" alt="Yahoo_HK_Enterpr1se" src="/wp-content/uploads/2013/05/Yahoo_HK_Enterpr1se-640x305.png" width="640" height="305" /></a>

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relative Image URLs
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.