Support » Plugin: SVG Support » Specify SVG width and height dimensions

  • Resolved Russ

    (@gfxdesigner)


    Hello,

    To reduce layout shifts and improve CLS, would it be possible for this plugin to pull the meta sizes from uploaded SVGs? While sizes are defined by CSS, it would be great to have the ability to list the width and height dimensions of SVGs.

    Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Hi Russ,

    This is on the list to be developed this month 🙂

    Thanks for your support and for noticing this.

    Thread Starter Russ

    (@gfxdesigner)

    That’s fantastic news! Thank you for your hard work on this plugin to benefit all of us.

    Plugin Author Benbodhi

    (@benbodhi)

    My pleasure!
    This issue is becoming much more noticeable these days and I’ve been meaning to work on it for a while. But now I finally can 🙂

    I’ll be adding quite a lot of new features and making it more powerful too.

    +1, this is important as this will also fix an issue with the Gutenberg editor when using SVGs as site logos.
    @see https://github.com/WordPress/gutenberg/issues/36603#issuecomment-1013225630

    Edit: Other plugins for SVG support sadly don’t do this (completely) either…

    • This reply was modified 6 months, 3 weeks ago by strarsis.
    Plugin Author Benbodhi

    (@benbodhi)

    Hi there,

    So upon checking this, I found that I have already written code to use the dimensions from the SVG itself.

    Can you please help me reproduce the issue so I can figure out what you’re experiencing?

    I had totally forgotten that I’d already addressed the dimensions metadata 🤦‍♂️

    Thanks in advance!

    @benbodhi: Without using an additional filter handler the issue also occurs with this plugin. The wp_get_attachment_image_src filter or a filter upstream is not addressed that is used by Gutenberg editor.

    Set a SVG image as site logo. Then add a site logo block into the Gutenberg editor.
    In backend and frontend the division-by-zero error should then occur.

    Adding an additional handler for wp_get_attachment_image_src that prevents non-existing or zero width/height for SVG images fixes the issue: https://github.com/WordPress/gutenberg/issues/36603#issuecomment-1013709271

    Plugin Author Benbodhi

    (@benbodhi)

    Thank you for clarifying @strarsis
    Working on it.

    Plugin Author Benbodhi

    (@benbodhi)

    Hi there,

    I believe this is fixed as of version 2.4 🙂

    I have pushed it to trunk already for testing and will push live for normal updating in the next few hours.

    Please do let me know if you have this issue still after updating, but all my tests are coming up clear.

    Thread Starter Russ

    (@gfxdesigner)

    In Divi when I add a “Blurb” module and add an SVG under “Image & Icon”, it doesn’t pull the image dimensions. If I switch it to something other than an SVG, it works appropriately.

    The same is true when adding a logo within Divi’s Theme Options > General.

    By the way, thanks for pushing out the recent update. Nice additional features in there!

    Plugin Author Benbodhi

    (@benbodhi)

    Hi @gfxdesigner

    Thanks for pointing this out. I’ll test with Divi today, specifically the things you have mentioned and see if I can reproduce and fix.

    Plugin Author Benbodhi

    (@benbodhi)

    Hey @gfxdesigner
    I wasn’t able to see the issue with the Divi blurb. But I just pushed another update that may have dealt with this issue anyway. Let me know.

    And thanks for the kind words!

    Plugin Author Benbodhi

    (@benbodhi)

    I’ll close this thread as the original issue is sorted.
    But please do open a new one if you face any further issues with the Divi theme or anything else.

    strarsis

    (@strarsis)

    I can confirm that with the latest version (2.4.2) of this plugin the division by zero error in Gutenberg for SVG images is resolved now.

    Plugin Author Benbodhi

    (@benbodhi)

    Hi @strarsis
    Thanks for confirmation.
    In fixing that issue, unfortunately it has made any previously uploaded SVGs that didn’t have dimensions display at 1px and seemingly disappear from view, so I’m currently figuring out how to address that.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Specify SVG width and height dimensions’ is closed to new replies.