Actually, the post_gallery
filter is intended for plugin authors who want to completely replace the gallery shortcode functionality. If you look at the code, you can see that the filter is at the beginning of the function, and that you’re actually filtering an empty string.
I definitely think there should be a filter at the end of the shortcode to amend a WP gallery, and I’m a bit surprised one doesn’t exist already. I went ahead and submitted this ticket to try to get it added to core.
Until that ticket takes effect (if it ever does), I don’t think there’s a way to add your awesome lightbox to a standard WP gallery if it’s added outside the main post content area (aside from copying the entirety of the gallery_shortcode
function), unless you can get it to work without having to rely on inline attributes on those image elements.