Archived topic
CLS issue still after setting dimensions on site logo
19 replies · Started by Randy on April 17, 2021
Hmmm... unfortunately not appearing. Please see image in private info. Ideas?
Ah, I see what is happening now: The logo inside "sticky-navigation-logo" IS getting its width and height set correctly. Also correct is the logo inside "site-logo mobile-header-logo"
However, the logo inside "header-image is-logo-image" does NOT have width or height attributes set.
Ah, I see the issue. The logo when using the navigation as the header doesn't have dimensions by default. We must have missed this in 2.0.
It's not really something we can do in a point release, as it needs to be tested, but there is a workaround for now until 2.1.0:
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;
} );
Yep, that did the trick! Thanks Tom!
No problem!