[Support request] Image elements do not have explicit width and height

Home Forums Support [Support request] Image elements do not have explicit width and height

Home Forums Support Image elements do not have explicit width and height

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1961985
    Fabien

    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

    #1962024
    David
    Staff
    Customer Support

    Hi there,

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

    #1962120
    Fabien

    No but that’s how SVG works in WordPress

    #1962439
    David
    Staff
    Customer Support

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

    2021-10-13_17-45-15

    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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.