[Support request] Logo does not have explicit width and height

Home Forums Support [Support request] Logo does not have explicit width and height

Home Forums Support Logo does not have explicit width and height

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #1733104
    ETO

    Hello,
    When I test my website with Google Pagespeed Insights, it says that the logo does not have explicit width and height. However, there was not such an error a few weeks ago although I haven’t done any changes on the site.

    #1733169
    Ying
    Staff
    Customer Support

    Hi there,

    Elvin’s answer here should be helpful:
    https://generatepress.com/forums/topic/tamano-recomendado-para-logo/#post-1696616

    Let me know 🙂

    #1734521
    ETO

    Thanks, but I think this is a problem that should be fixed with a theme update. Why do I have to add extra code snippets to solve such a problem that should not exist at all?

    #1734646
    Elvin
    Staff
    Customer Support

    Hi there,

    It’s one of the things Tom is working on for the next update. Please look forward to it. 🙂

    #1760169
    ETO

    Hello, Elvin!
    You released the update and I updated my site but it seems that you haven’t fixed this issue yet.

    #1761012
    Elvin
    Staff
    Customer Support

    Hi there,

    Are you still using the filter? Can you try removing it?

    You then remove the logo on the customizer, save it, refresh the customizer page, and re-add it again. Let us know how it goes.

    #1761695
    ETO

    I don’t use any filter and did what you asked (remove the logo on the customizer, save it, refresh the customizer page, and re-add it again). However, the problem still exists.

    #1762272
    Tom
    Lead Developer
    Lead Developer

    This fix didn’t make it into the Navigation as Header option which you’re using – our mistake.

    For now, you need this filter:

    add_filter( 'generate_logo_attributes', function( $attributes ) {
        $data = wp_get_attachment_metadata( get_theme_mod( 'custom_logo' ) );
    
        if ( ! empty( $data ) ) {
            $attributes['width'] = $data['width'];
            $attributes['height'] = $data['height'];
        }
    
        return $attributes;
    } );

    It will fix the issue and continue to work even when we fix it in the theme 🙂

    #1766354
    ETO

    Thanks, Tom but I would like to wait for the update to fix this issue. 🙂

    #1773993
    ETO

    Hello!
    When will the update fixing this problem be released?

    #1774729
    Tom
    Lead Developer
    Lead Developer

    This will be in GP Premium 2.1 which doesn’t have a release date right now.

    However, this function I provided is update-safe and completely solves the problem: https://generatepress.com/forums/topic/logo-does-not-have-explicit-width-and-height/#post-1762272

    There’s no reason not to add it as a solution for now 🙂

    #1809993
    John Retzer

    Forgive this non-tech guy’s question: WHERE do I add that code?

    #1810037
    David
    Staff
    Customer Support

    This article explains how to add that PHP Code:

    https://docs.generatepress.com/article/adding-php/

    TLDR: If you have a Child Theme installed then you paste the code into the Child Themes functions.php – NOT using a Child Theme ? Then install the Code Snippets plugin, create a new Snippet and paste the code in there.

    #1847078
    Clayton

    Hey guys,

    I’ve added this function but for some reason it isn’t working but only on this website. On all the other websites I’ve added this function to it has fixed the issue. I’ve cleared cache several times but I still can’t figure out why it isn’t working on this website.

    #1847084
    Elvin
    Staff
    Customer Support

    Hi Clayton,

    Hey guys,

    I’ve added this function but for some reason it isn’t working but only on this website. On all the other websites I’ve added this function to it has fixed the issue. I’ve cleared cache several times but I still can’t figure out why it isn’t working on this website.

    Can you specify which one are you using?

    If you’re using GP Premium 2.0, you won’t be needing the PHP snippet as it’s already patched.

    Once you’ve updated, you can remove and re-add the logo. This act should automatically generate the missing image height and width attribute.

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