Site logo

Archived topic

Set height and width for the logo image

5 replies · Started by Dong on June 19, 2021

Viewing posts 1–6 of 6

Hi guys,

I have the logo's explicit height and width issue:

https://dongknows.com

https://developers.google.com/speed/pagespeed/insights/?url=dongknows.com

Currently, I have this issue with (just) the logo image. The code Elvin mentioned here:

https://generatepress.com/forums/topic/how-to-set-height-and-width-for-the-logo-image/page/2/#post-1827778

fix the logo error but subequently caused the same error on ALL featured images of the Archive page. Here's the code I used:

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="341" height="132" src="%3$s" alt="%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 ) )
	);
}

Please help!

Thanks,

-Dong.

That fixed it. Thanks, David.

Glad to hear that!

Hi Dong,

I believe there's no need for this code if you're already using GP Premium 2.0 or newer.

To fix this, you simply have to reupload and reassign it again on the Site Identity settings. This should generate the missing attributes.

Note: The code snippet I've provided only works with the logo. It shouldn't affect any other images. https://github.com/tomusborne/generatepress/blob/b60b853630da6d9015722da903e53c8064148b0a/inc/structure/header.php#L151-L165

This archived topic is closed to new replies.