This is a bit difficult to do on my phone. But this should work.
Code:
$s = preg_replace("/\[img\]http:\/\/([^\s'\"<>]+(\.gif|\.jpg|\.png))\[\/img\]/", "<img border=\"0\" src=\"https://images.weserv.nl/?url=ssl:\\1\">", $s);
It seems that you changed your needs from your first post.
Code:
$s = preg_replace("/\[img\]http:\/\/([^\s'\"<>]+(\.(jpg|gif|png))\[\/img\]/i", "<a href=\"\\1\" target=\"_self\"><img border=\"0\" src=\"https://images.weserv.nl?url=ssl:\\1\"></a>", $s);