Skip to content

Local SVG images with percentage width are not sized correctly #135

Open
@na3shkw

Description

@na3shkw

What information was incorrect, unhelpful, or incomplete?

SVG images with a percentage value set in the width attribute of the svg element are not displayed at the correct size.
For example, if you have a local SVG image with width="100%" set on the svg element, the attribute on the img element that displays it will be set to width="100".

What did you expect to see?

The width of an SVG image with a percentage value for the width attribute should be determined based on the value of the viewBox attribute.

Do you have any supporting links, references, or citations?

Do you have anything more you want to share?

I believe this problem can be solved by using the width method to get the width of the image in the following code, instead of directly referencing the width of the Width structure. If the value of the width attribute of the svg element is specified as a percentage, the width method will calculate the width of the image based on the viewbox.

let width = meta.width.map(|w| w.width);

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions