SVG with no explicit width and height is not rendered correctly in GUI

Hello!

We noticed some problems with SVG files that don’t have an explicit width and height attribute on their root element.

Safari works as expected. Chrome renders with wrong dimensions. Firefox does not render.

I would suggest a fallback to the viewbox attribute for width and height.

2 Likes

There is no magic in the way we deal with SVGs. for us they are nothing more than images that are loaded using the browser’s Image object.
Would you be able to share the svg (and maybe a quick playground) so that we can see that the best way to get all browsers to work the same?

I will prepare a playground.

In this method you are using the attributes to calculate the dimensions, this should also work without the width and height attributes.

1 Like

You are totally right. @msDestiny14 - want to take this one?

This is probably the best solution.

And here is a sentence we hardly ever read.

3 Likes

Ha! Ain’t that the truth. Appreciate your attention on this, @RaananW and @msDestiny14 !

1 Like

Yep! Poke me when you have a PG and I will test and push. Nice find. :slight_smile:

Finished the PG @msDestiny14

https://www.babylonjs-playground.com/#QEPV26#3

3 Likes