EDIT: Sorry all, I found a bug that causes Fancybox to be bound twice.
Please remove the original functions I provided (the original post has been updated for anyone who did not use the original code and is new here) and replace with just this block
// Chat fancybox - fires when chat module loaded and AJAX calls new chat
$(document).ready(function() {
$(window).on('action:chat.loaded', function(data) {
this.$('img').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() {
var newHref = $(this).attr("src");
$(this).wrap("<a class='fancybox' href='" + newHref + "'/>");
$('a[href*=".jpg"], a[href*=".jpeg"], a[href*=".png"], a[href*=".gif"], a[href*=".webp"]').addClass("noanimate");
data.preventDefault();
// Strip out the images contained inside blockquotes as this looks nasty :)
$('blockquote img').remove();
});
Fancybox.bind(
'a[href*=".jpg"], a[href*=".jpeg"], a[href*=".png"], a[href*=".gif"], a[href*=".webp"]', {
groupAll: true,
}
);
});
});