Site logo

Archived topic

Image elements do not have explicit width and height

3 replies · Started by Fabien on October 13, 2021

Viewing posts 1–4 of 4

Hi,

Using GP Premium 2.1.0 beta, I've read that width and height should be automatically added to the logo(s). I've tried, and it's not working. Is it because I am using an SVG logo ?

Thanks

Hi there,

if you check your SVG Logo image in the Media Library does it display a Width and Height value?

No but that's how SVG works in Wordpress

Its dependent on the build of the SVG. See here for example:

https://www.screencast.com/t/35r1PyMWPdl

If theres no width x height it means the SVG doesn't have those attributes, which means WP has to try and process the size based on the viewBox data. Which its terrible at doing.

If you can't 'fix' the SVG then you can use the snippet provided here to add width height attributes to the logo img HTML:

https://generatepress.com/forums/topic/svg-logo-image-dimensions-incorrect-causes-layout-shift/#post-1850189

This archived topic is closed to new replies.