Many thanks for the feedback.
i changed it in my child theme as follows:
function register_assets()
{
// Your existing wp_register_style and wp_register_script code
$baguettebox_selector = apply_filters('baguettebox_selector', '.wp-block-gallery,:not(.wp-block-gallery)>.wp-block-image,.wp-block-media-text__media,.gallery,.wp-block-coblocks-gallery-masonry,.wp-block-coblocks-gallery-stacked,.wp-block-coblocks-gallery-collage,.wp-block-coblocks-gallery-offset,.wp-block-coblocks-gallery-stacked,.mgl-gallery,.gb-block-image');
$baguettebox_filter = apply_filters('baguettebox_filter', '/.+\.(gif|jpe?g|png|webp|svg|avif|heif|heic|tif?f|)($|\?)/i');
$script = 'window.addEventListener("load", function() {
baguetteBox.run("' . $baguettebox_selector . '", {
captions: function(element) {
var img = element.querySelector("img");
return img ? img.getAttribute("alt") : "";
},
filter: ' . $baguettebox_filter . '
});
});';
wp_add_inline_script('baguettebox', $script);
}
add_action('wp_enqueue_scripts', 'register_assets');