• Resolved Marcus Spanier

    (@espiat)


    Hi.
    I am searching a php code filter for:
    i will not show the caption text in the lightbox, instead the alt text of the image.

    is there a build in filter or hook for this in the plugin?

    thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Johannes Kinast

    (@goaroundagain)

    Thread Starter Marcus Spanier

    (@espiat)

    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');
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter for Alt Tag not Caption in Lightbox’ is closed to new replies.