Skip to content

svgs not displaying correctly with passthroughImageService #14962

@eya46

Description

@eya46

Astro Info

Astro (>=5.15.9)

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

No response

Describe the Bug

copy from #14861

After upgrading to the latest Astro (>=5.15.9), all SVG images stopped displaying.

Issues found:

  • With passthroughImageService enabled, SVG images return Content-Type: image/null and fail to render (JPG works).

After downgrading Astro, the regression starts at 5.15.9.
Related issues:

delete newOptions.format; -> "Content-Type": mime.lookup(format) ?? `image/${format} -> Browser Content-Type: image/null -> image boom (svg)

Changes

I believe the issue in #14721 originates from the options.format = DEFAULT_OUTPUT_FORMAT assignment in service.ts.
To address this, I added a flag to prevent setting a default output format when the noop service is used.

Although my JPG images still return image/null (but browsers can display them), SVG images now work correctly.

before:
image

image

after:
image

image

What's the expected result?

correctly display svg images

Link to Minimal Reproducible Example

https://stackblitz.com/edit/eya46-astro-svg-bug

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions