Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
na3shkw opened this issue Feb 24, 2025 · 0 comments
Open

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

na3shkw opened this issue Feb 24, 2025 · 0 comments
Labels
needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@na3shkw
Copy link

na3shkw commented Feb 24, 2025

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);

@na3shkw na3shkw added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

No branches or pull requests

1 participant