A few years back I wrote about how to get Fancybox 1 working on WP galleries – specifically how to add a
rel tag to an image anchor tag so that images would appear grouped in their correct galleries.
That all became obsolete with the introduction of the Gutenberg block editor, as images and galleries are now inserted into posts and pages in completely different ways.
Before, there were plenty of filters available to change image and wrapping anchor tags relatively easily, but my attempts to do something server-side and php-based with the block editor met with total failure. Instead I ended up upgrading to Fancybox 3 and using jQuery to sort pretty much everything out.