Skip to content

SVG loader fails with missing viewBox #13280

@adamalfredsson

Description

@adamalfredsson

Astro Info

Astro                    v5.3.0
Node                     v20.12.2
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         @astrojs/svelte
                         @astrojs/react
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I want to use an SVG pattern which doesn't have a viewBox, such as this one:

<svg width="200" height="100%">
  <defs>
    <pattern id="stripes" patternUnits="userSpaceOnUse" width="10" height="10">
      <rect width="5" height="10" fill="#000" />
    </pattern>
  </defs>
  <rect width="100%" height="100%" fill="url(#stripes)" />
</svg>

But, using the experimental svg loader, I get error:

NoImageMetadata
Could not process image metadata.

With astro-icon v0 this was no problem
With astro-icon v1 I could override the viewBox property, by setting it to undefined on the Icon component

What's the expected result?

SVG should load

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gjg3z579

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P2: nice to haveNot breaking anything but nice to have (priority)feat: assetsRelated to the Assets feature (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions