Quote:
Originally Posted by Tedmorris
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.