• Resolved bluisier

    (@bluisier)


    Dear Florian,

    I’have been using your plugin for a while now and love it’s quality and flexibility. Thanks again for your great work and support.

    I’ve been manually using your filter_markup() function in my theme to enable lazyloading on category pages (with category descriptions) the following way

    add_filter( 'genesis_term_intro_text_output','archive_images_responsive', 1);
    function archive_images_responsive($archive_description) {
        $archive_description = wp_make_content_images_responsive($archive_description);
        if(class_exists( 'FlorianBrinkmann\LazyLoadResponsiveImages\Plugin' )) {
            $lazyloader = new \FlorianBrinkmann\LazyLoadResponsiveImages\Plugin;
            $archive_description = $lazyloader->filter_markup($archive_description);
        }
        return $archive_description;
    }

    But since version 3.5.0, I get the following error on all my category pages (in local):

    Fatal error: Uncaught Error: Call to a member function is_admin_request() on null in /var/www/html/web/app/plugins/lazy-loading-responsive-images/src/Plugin.php:183

    I might be doing smthing wrong… any suggestions???

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hey @bluisier,

    happy to hear that you like the plugin, thanks! ??

    Sorry for the issue with the error, I moved a little bit of code for the 3.5.0 release that causes the problem (I think). Could you try adding the following line after the new call and before calling the filter_markup() method?

    $lazyloader->init();
    

    That should fix it.

    Best,
    Florian

    Thread Starter bluisier

    (@bluisier)

    Works like a charm… thanks again for the great support!

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    You’re welcome! Great to hear that it works again ??

    Best,
    Florian

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hi @bluisier,

    just as a follow-up: I released 4.0.0 of the plugin and now it should be possible to use the following code in a theme:

    add_filter( 'genesis_term_intro_text_output','archive_images_responsive', 1);
    function archive_images_responsive($archive_description) {
        $archive_description = wp_make_content_images_responsive($archive_description);
        if ( isset( $lazy_loader ) && $lazy_loader instanceof FlorianBrinkmann\LazyLoadResponsiveImages\Plugin ) {
            $archive_description = $lazy_loader->filter_markup( $archive_description );
        }
        return $archive_description;
    }
    

    A little shorter and does not create a new object of the plugin class ??

    If you choose to give that way a try, it would be great if you could report if that is working for you!

    Best,
    Florian

    Thread Starter bluisier

    (@bluisier)

    Yes I’ll give it a try next time I update the plugins and report it to you here… thanks for the great work

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Great, thanks!

    Thread Starter bluisier

    (@bluisier)

    Hey @florianbrinkmann ,

    I tried the code you mentioned above in my theme but the $lazy_loader is NULL… it seems I still need to create a new object of the plugin class to make it work for me.

    At the moment I still use the fonction this way this way:

    
    add_filter( 'genesis_term_intro_text_output','archive_images_responsive', 1);
    function archive_images_responsive($archive_description) {
        $archive_description = wp_make_content_images_responsive($archive_description);
        if(class_exists( 'FlorianBrinkmann\LazyLoadResponsiveImages\Plugin' )) {
            $lazy_loader = new \FlorianBrinkmann\LazyLoadResponsiveImages\Plugin;
            $lazy_loader->init();
            $archive_description = $lazy_loader->filter_markup($archive_description);
        }
        return $archive_description;
    }
    

    Am I missing something?

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Hi @bluisier,

    thanks for testing! Could you try this (with the global $lazy_loader;)? I think the issue was that I tested it outside of a function, and the $lazy_loader is not accessible inside functions without the global $lazy_loader; line.

    add_filter( 'genesis_term_intro_text_output','archive_images_responsive', 1);
    function archive_images_responsive($archive_description) {
        global $lazy_loader;
        $archive_description = wp_make_content_images_responsive($archive_description);
        if ( isset( $lazy_loader ) && $lazy_loader instanceof FlorianBrinkmann\LazyLoadResponsiveImages\Plugin ) {
            $archive_description = $lazy_loader->filter_markup( $archive_description );
        }
        return $archive_description;
    }

    Thanks!
    Florian

    Thread Starter bluisier

    (@bluisier)

    yes of course it makes sense ;)… Now it works like a charm and this solution is cleaner!

    Plugin Author Florian Brinkmann

    (@florianbrinkmann)

    Great, thanks for testing! ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Fatal error since version 3.5.0’ is closed to new replies.