Skip to content

fix: Support xlinkHref attribute for SVG image elements#724

Merged
shuding merged 3 commits intomainfrom
copilot/fix-xlinkhref-attribute
Mar 2, 2026
Merged

fix: Support xlinkHref attribute for SVG image elements#724
shuding merged 3 commits intomainfrom
copilot/fix-xlinkhref-attribute

Conversation

Copy link
Contributor

Copilot AI commented Feb 7, 2026

SVG <image> elements only recognized href as the image source attribute, causing errors when using the JSX/React-compatible xlinkHref prop.

// This worked
<svg><image href="data:image/..." /></svg>

// This threw "Image source is not provided"
<svg><image xlinkHref="data:image/..." /></svg>

Changes

src/handler/preprocess.ts

  • Line 125: Check both href and xlinkHref when resolving image data from cache
  • Lines 159-166: Collect image sources from both props.href and props.xlinkHref during preprocessing

test/image.test.tsx

  • Added test case with xlinkHref attribute including xmlns:xlink namespace declaration

The existing ATTRIBUTE_MAPPING already handles the xlinkHrefxlink:href conversion for SVG output.

Original prompt

This section details on the original issue you should resolve

<issue_title>xlinkHref isn't interpreted as source for <image /> in SVGs</issue_title>
<issue_description># Bug report

Description / Observed Behavior

Using namespaced attribute in JSX form like xlinkHref instead of xlink:href causes error "Image source is not provided" to be thrown.

Expected Behavior

Satori should use the JSX/TSX attribute xlinkHref as the <image /> source, interpreting it the same it does xlink:href and href.

Reproduction

Using xlink:href (works)

[Using xlinkHref (doesn't work)](https://og-playground.vercel.app/?share=5Vlpb-LIFv0riNGT-sk98YI3Mt0jGTCLbQx4w0aRRt6wDd5XoNX__ZUJJCQ9ip70kg9vYilR1anruvcc36q62D-6duK43fvuNyeoH-JOpyiPofv9x4-23en4buD55X3noYsiyL8eul8f4SZwSv8X1AmKNDSPLb4N3cMT3nZGQe7aZZDE7aidhFUUP42bYeDFs9KNivOgG5du_jS4q4oy2B6HCUDjcySvDLZgRA5O7n2HQLEbbH0JnUSQC1q6h5Jpff0yy8-fD_GfbeNbUXs3FL8_dHsI8tC9FeMlVgduM0gOAEQ6SAcMtH_XwW0QhmAkTmL3Ch2iMC4A5pdleg_DTdPcNb27JPdgDEEQuH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jVfkIs4NTeZE9vIuKYgmOiTqi8jhbCQguUJhzJRywjbINAab5bD7dKy5-Z6VoqlloXISNqRGjOUgmKQEGsGUVM2jVZqfsr285wzhFm6WauJp_M...


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Contributor

vercel bot commented Feb 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
satori-playground Ready Ready Preview, Comment, Open in v0 Feb 7, 2026 1:42pm

Co-authored-by: shuding <3676859+shuding@users.noreply.github.com>
Co-authored-by: shuding <3676859+shuding@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix interpretation of xlinkHref for image source in SVGs Support xlinkHref attribute for SVG image elements Feb 7, 2026
Copilot AI requested a review from shuding February 7, 2026 13:45
@shuding shuding changed the title Support xlinkHref attribute for SVG image elements fix: Support xlinkHref attribute for SVG image elements Mar 2, 2026
@shuding shuding marked this pull request as ready for review March 2, 2026 13:31
@shuding shuding merged commit f4729fe into main Mar 2, 2026
6 checks passed
@shuding shuding deleted the copilot/fix-xlinkhref-attribute branch March 2, 2026 13:31
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

🎉 This PR is included in version 0.19.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

shuding added a commit to vercel/next.js that referenced this pull request Mar 5, 2026
The new `@vercel/og` and `satori` include many improvements:
- 2~20x faster image generation (`ImageResponse` API) by using Sharp for
rasterization, and optimized Satori core
- Better CSS/SVG coverage:
  - vercel/satori#736
  - vercel/satori#734
  - vercel/satori#733
  - vercel/satori#732
  - vercel/satori#728
  - vercel/satori#724
  - vercel/satori#717
  - vercel/satori#718
  - vercel/satori#719
- Updated layout engine (vercel/satori#689):
  - Support for `box-sizing`
  - Support for `display: contents`
  - Support for `position: static`
  - Support for `align-content: space-evenly`
  - Better support for `position: absolute`
  - Support for percentage values for `gap`
- Noto Sans → Geist Sans
sokra pushed a commit to vercel/next.js that referenced this pull request Mar 6, 2026
The new `@vercel/og` and `satori` include many improvements:
- 2~20x faster image generation (`ImageResponse` API) by using Sharp for
rasterization, and optimized Satori core
- Better CSS/SVG coverage:
  - vercel/satori#736
  - vercel/satori#734
  - vercel/satori#733
  - vercel/satori#732
  - vercel/satori#728
  - vercel/satori#724
  - vercel/satori#717
  - vercel/satori#718
  - vercel/satori#719
- Updated layout engine (vercel/satori#689):
  - Support for `box-sizing`
  - Support for `display: contents`
  - Support for `position: static`
  - Support for `align-content: space-evenly`
  - Better support for `position: absolute`
  - Support for percentage values for `gap`
- Noto Sans → Geist Sans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xlinkHref isn't interpreted as source for <image /> in SVGs

2 participants