Repository navigation
Preview binary images in the workspace editor - #78
Open
rushabhcodes wants to merge 3 commits into
Open
rushabhcodes wants to merge 3 commits into
rushabhcodes wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
imrishabh18
reviewed
Oct 12, 2026
imrishabh18
left a comment
Member
There was a problem hiding this comment.
I am not sure if we need this or not. cc @seveibar
Just make sure that we don't load huge images, cause that can freeze the editor
Contributor
Author
|
will add a limit |
Contributor
Author
|
@imrishabh18 Previews now reject images over 5 MiB |
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening a binary PNG currently shows “This file cannot be displayed in the editor.” This change opens supported binary images in a fitted preview with a transparency checkerboard and download link.
The preview uses the blob or image data URL already stored in
content, falling back todownloadUrlwhen needed. This avoids a second request for authenticated files. Failed image loads show a fallback message, other binary files keep the download notice, and text SVG files remain editable.Previews are limited to 5 MiB of encoded data, 16 million pixels, and 8192 pixels per side. Encoded headers are checked before an image element is created; oversized images keep a download-only fallback. Response bodies are read with a byte limit even when Content-Length is absent. Pending checks are canceled on file changes or after 10 seconds, and temporary preview URLs are revoked on cleanup. Only validated bytes are rendered, avoiding a second network request or a changing remote resource.
Adds nine interactive Cosmos examples in
examples/binary-files.fixture.tsx: PNG blob URLs, JPEG data URLs, PNG download URLs, failed images, missing image URLs, unsupported binary files, editable SVG source, oversized files, and oversized dimensions. Runbun run devand open thebinary-filesfixtures; every example includes a sidebar for switching between images and code, with locally generated sample images.Before
After
Validation:
bun test: 71 tests pass.bun run typecheck,bun run build, andbun run format:checkpass.