<?php

$message = '<p>С этой формы приходят заявки <a href="https://s...content-available-to-author-only...e.com/lack_tech.php">https://s...content-available-to-author-only...e.com/lack_tech.php</a></p>
<p>Или что ты имеешь ввиду?</p>
<div class="attachment_files_message"> 
   <p>Прикреплённые файлы:</p>
   <a href="http://s...content-available-to-author-only...e.com/public/uploads/kylticket/2670/Screenshot_1.png" target="_blank">Screenshot_1.png</a>
</div>';
$message = preg_replace('~<a\s+((?:[^\s<>\'"=]+(?:=(?:"[^"]*"|\'[^\']*\'|[^\s\'">]+))?\s+)*)href=(?|"([^"]*\.(?:jpe?g|png))"|\'([^\']*\.(?:jpe?g|png))\'|([^\s\'">]*\.(?:jpe?g|png))(?=[>\s]))((?:\s+[^\s<>\'"=]+(?:=(?:"[^"]*"|\'[^\']*\'|[^\s\'">]+))?)*)\s*>(.*?)</a>~is', 
        '<a $1$3 data-fancybox="gallery" href="$2"><img src="$2" alt="" class="tmp_class"></a>',
        $message);
echo $message;