Archived topic
Logo width and height in header
5 replies · Started by Chloe on March 18, 2021
Hi there
I am having a couple of issues with defining image sizes on my pages. The main one being the logo header image. I think if I can resolve this one then I should be able to resolve the other issue. I have tried to implement the solution here: https://generatepress.com/forums/topic/how-to-set-height-and-width-for-the-logo-image/#post-1563234, but it doesn't seem to be working.
I have included the link on Page speed insights. You can see there are two images, the logo and an author profile pic at the bottom of the page.
Any help would be amazing.
Many thanks
Chloe
Hi there,
The PHP snippet David provided should work for the mobile view.
Are you referring to the desktop or mobile here?
Let me know :)
Hi Leo
Thanks for your reply.
It's in mobile. I have added the snippet, the it is still coming up in insights as an issue.
Thanks Chloe
David's snippet is for the mobile header logo which you aren't using.
Try this snippet instead:
add_filter( 'generate_logo_output','tu_logo_atts', 10, 2 );
function tu_logo_atts( $output, $logo ) {
printf(
'<div class="site-logo">
<a href="%1$s" title="%2$s" rel="home">
<img width="330" height="58" class="header-image" src="%3$s" alt="%2$s" title="%2$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_logo', $logo ) )
);
}
It should work for both desktop and mobile
Hi Leo!
This worked great. Thank you.
Chloe
No problem :)