Site logo

Archived topic

Add Image Class to Sticky Menu Logo

8 replies · Started by Mindy on April 11, 2020

Viewing posts 1–9 of 9

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!! :)

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!

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

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' ) ) )
    );
} );

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

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!!

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

Thank you, as always Leo!

No problem :)

This archived topic is closed to new replies.