$text = "Here are some links: https://example.com/page.html, and a jpg image link: https://images.example.com/pic.jpg. Also another url: www.test.net. And a image: site.com.";
$pattern = '/\bhttps?:\/\/(?!\S+(?:jpe?g|png|gif)\b)\S+/i';

"/(a href=.?)(https?.{4}(?!\S+(?:jpe?g)\b))\s/"=>"$1?csurl=$2 ",