- This topic has 24 replies, 7 voices, and was last updated 2 years, 6 months ago by Elvin.
-
AuthorPosts
-
April 13, 2021 at 11:38 am #1733104ETO
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.April 13, 2021 at 1:02 pm #1733169YingStaffCustomer SupportHi there,
Elvin’s answer here should be helpful:
https://generatepress.com/forums/topic/tamano-recomendado-para-logo/#post-1696616Let me know 🙂
April 14, 2021 at 12:17 pm #1734521ETOThanks, 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?
April 14, 2021 at 4:38 pm #1734646ElvinStaffCustomer SupportHi there,
It’s one of the things Tom is working on for the next update. Please look forward to it. 🙂
May 2, 2021 at 5:30 am #1760169ETOHello, Elvin!
You released the update and I updated my site but it seems that you haven’t fixed this issue yet.May 2, 2021 at 5:16 pm #1761012ElvinStaffCustomer SupportHi 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.
May 3, 2021 at 4:55 am #1761695ETOI 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.
May 3, 2021 at 8:48 am #1762272TomLead DeveloperLead DeveloperThis 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 🙂
May 5, 2021 at 12:59 pm #1766354ETOThanks, Tom but I would like to wait for the update to fix this issue. 🙂
May 11, 2021 at 4:46 am #1773993ETOHello!
When will the update fixing this problem be released?May 11, 2021 at 10:27 am #1774729TomLead DeveloperLead DeveloperThis 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 🙂
June 4, 2021 at 6:38 am #1809993John RetzerForgive this non-tech guy’s question: WHERE do I add that code?
June 4, 2021 at 7:19 am #1810037DavidStaffCustomer SupportThis 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.
July 6, 2021 at 4:25 pm #1847078ClaytonHey 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.
July 6, 2021 at 4:45 pm #1847084ElvinStaffCustomer SupportHi 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.
-
AuthorPosts
- You must be logged in to reply to this topic.