• Good plugin, what you need! The only thing that could be corrected in it: so that it displays its styles (.css) and scripts (.js) only in posts, and not everywhere 🙂 Well, or so that you can choose where to turn it on … It would be just great!

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

    (@goaroundagain)

    Hi @bro007,

    The Plugin tries to detect, if there is a supported Gallery/Image Block present on the page and only loads the style & script for performance reason than. If you just have one gallery on your website, your users only have to download the script & style and execute it if they are really necessary.

    If you want to change this behavior on your site, just add this snippet to your functions.php:
    add_filter( 'baguettebox_enqueue_assets', '__return_true' );

    Thread Starter bro007

    (@bro007)

    When adding: add_filter( ‘baguettebox_enqueue_assets’, ‘__return_true’ ); – everything remains as it is (all scripts and plugin styles are also displayed on all pages, that is, nothing changes). I need them to be displayed only in posts (I have galleries in posts).

    Thread Starter bro007

    (@bro007)

    I wrote about the fact that it would be nice if the plugin added scripts and styles, only where there are galleries. I have them in posts, and the plugin adds them more: in archives, on panigation pages. This is what I meant … (although this is not critical).

    Plugin Author Johannes Kinast

    (@goaroundagain)

    @bro007 I am sorry, I misunderstand your review. In fact, the plugin tries to detect if there is a supported gallery/image Block on the page and only loads the script & styles if necessary. There can be some false positive, e.g. on an archive page where there is only the excerpt displayed, but there is an image/gallery block in a post. I think this is better than false negative cases.

    With the baguettebox_enqueue_assets filter you can control where the script & styles should be loaded: https://wordpress.org/plugins/gallery-block-lightbox/#how%20to%20enqueue%20the%20necessary%20assets%20%28script%20%26%20style%29%20for%20blocks%20outside%20of%20posts%20or%20for%20block%20types%20that%20are%20not%20supported%20by%20default%3F

    This should apply your desired behavior: (not tested)
    add_filter( ‘baguettebox_enqueue_assets’, function() { return is_single(); } );

    Thread Starter bro007

    (@bro007)

    Thank you for your attention 🙂 Yesterday I found a function with which I achieved the desired result, and also removed other styles on my site with its help:

    function disable_scripts_styles(){
    if ( !is_single() ) {
    wp_dequeue_style( ‘baguettebox-css’ );
    wp_dequeue_script( ‘baguettebox’ );
    }
    }
    add_action( ‘wp_enqueue_scripts’, ‘disable_scripts_styles’, 99 );

    Might be useful for someone… Thank you, your lightbox plugin is the best!

    Plugin Author Johannes Kinast

    (@goaroundagain)

    @bro007 this works, too.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Nice plugin’ is closed to new replies.