View Single Post
  #11  
Old 20th December 2018, 14:04
darkalchemy darkalchemy is offline
Administrator
 
Join Date: Dec 2017
United States
Posts: 101
Default
Quote:
Originally Posted by Tedmorris View Post
It echos https
That's what you are checking, https or http.

Bump: Lets backup a bit, my initial response was mostly correct, with one exception.

You do not check the $_SERVER['REQUEST_SCHEME'] of the image, that is for the request.

Here is a simple example, I have not tested it, but should work. You would add this after all images have been processed in format_comment().

Code:
if (empty($_SERVER['REQUEST_SCHEME']) || $_SERVER['REQUEST_SCHEME'] === 'https') {
    preg_match_all('/<img.*?src=["|\']http:.*?["|\'].*?>/s', $s, $matches);
    foreach ($matches[0] as $match) {
        preg_match('/<img(.*?)src=["|\'](http:.*?)["|\'](.*?)>/s', $match, $links);
        $dummy_image = "
        <a href='{$links[2]}'>
            <img{$links[1]}alt='Dummy Image' src='dummy.image.png'{$links[3]}>
        </a>";
        $s = str_replace($match, $dummy_image, $s);
    }
}
Sorry, for the confusion.

Last edited by darkalchemy; 20th December 2018 at 17:59.
Reply With Quote