[Resolved] Add Image Class to Sticky Menu Logo

Home Forums Support [Resolved] Add Image Class to Sticky Menu Logo

Home Forums Support Add Image Class to Sticky Menu Logo

  • This topic has 8 replies, 2 voices, and was last updated 4 years ago by Leo.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1235375
    Mindy

    Hello,

    I am using WP Rocket and the “lazy load images” option.

    This is creating an issue for the mobile sticky menu where it is not loading correctly initially.

    WP Rocket has an image class solution as can be seen here: https://docs.wp-rocket.me/article/15-disabling-lazy-load-on-specific-images

    How can I add this image class to the logo image? (If possible)

    Thank you!! πŸ™‚

    #1235410
    Leo
    Staff
    Customer Support
    #1235496
    Mindy

    Hi Leo, so far this is not working for me, even after clearing the cache. Is it possible that adjustments need to be made since I am using the sticky menu on mobile?

    Just thought I would ask, thank you!

    #1235539
    Leo
    Staff
    Customer Support

    Possible. Try excluding this class: sticky-navigation-logo

    #1235544
    Mindy

    Thanks Leo, this is what I have and it is not working, but I probably am misunderstanding something lol:

    add_filter( 'generate_mobile_header_logo_output', function( $output ) {
        if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
            return $output;
        }
    
        $settings = wp_parse_args(
            get_option( 'generate_menu_plus_settings', array() ),
            generate_menu_plus_get_defaults()
        );
    
        return sprintf(
            '<div class="sticky-navigation-logo">
                <a href="%1$s" title="%2$s" rel="home">
                    <img src="%3$s" data-no-lazy="1" alt="%4$s" />
                </a>
            </div>',
            esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
            esc_url( apply_filters( 'generate_mobile_header_logo', $settings['mobile_header_logo'] ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
        );
    } );
    #1235691
    Leo
    Staff
    Customer Support

    Sorry I thought you were going to use the solution WP Rocket provided?

    #1235711
    Mindy

    Ha, I knew I was misunderstanding something. I thought the article you linked was in place of the WP Rocket solution.

    I am not really sure what php code I should be using to solve my issue. Sorry to be a pain, but if you could be more specific in what code I should try, that would be amazing! Thank you very much!!

    #1236064
    Mindy

    This is resolved! WP Rocket went me a file name specific php code to use.

    Thank you, as always Leo!

    #1236361
    Leo
    Staff
    Customer Support

    No problem πŸ™‚

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.