Skip to content

Support Node.js object URLs as image sources#2601

Merged
chearon merged 1 commit into
Automattic:masterfrom
benitoalba:fix-2525-object-url-image-source
Jul 13, 2026
Merged

Support Node.js object URLs as image sources#2601
chearon merged 1 commit into
Automattic:masterfrom
benitoalba:fix-2525-object-url-image-source

Conversation

@benitoalba

Copy link
Copy Markdown
Contributor

Summary

  • resolve Node.js blob:nodedata: URLs through resolveObjectURL
  • pass the resolved Blob bytes through the existing Buffer image loader and preserve the original source URL
  • test successful loading and drawing, plus rejection after URL revocation
  • document the fix in the changelog

Why

Image#src only recognized data and HTTP(S) URLs. Node.js object URLs therefore fell through to local path handling and were passed to fopen, so onload never fired and the image could not be drawn.

Fixes #2525.

Testing

  • npx mocha test/image.test.js: 37 passing, 3 pending

  • npm run lint

  • npm run tsd

  • npm test: 301 passing, 7 pending; two pre-existing CanvasPattern/CanvasGradient save/restore failures on Windows also reproduce on unmodified master

  • Have you updated CHANGELOG.md?

@benitoalba
benitoalba marked this pull request as ready for review July 13, 2026 22:48

@chearon chearon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@chearon
chearon merged commit a1177f9 into Automattic:master Jul 13, 2026
19 checks passed
@benitoalba
benitoalba deleted the fix-2525-object-url-image-source branch July 13, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image#src= does not work with object URL (onload never called, cannot be drawn on 2d context)

2 participants