Если в $matches[0] хранится не массив, а обычная строка (с одной картинкой!), то вот:
if (preg_match('/<img[^>]+?alt="([^">]+)"/', $matches[0], $regs)) $matches[0] = str_replace('data-fancybox="gallary"', 'data-fancybox="gallary" alt="{$regs[1]}"', $matches[0]);