-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Image Component for Blazor #63360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Image Component for Blazor #63360
Conversation
…eaming of variable size
This reverts commit 3e674f7.
…for loading and error styling using css data-state
…helper, use AbortController for stale stream cancelation
Initial image component is in good shape, I'll compare with ASP.NET core now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new Image component for Blazor that efficiently renders images from non-HTTP sources such as byte arrays or streams. The component provides automatic browser-side caching, streaming support with progress tracking, and proper memory management through blob URL lifecycle management.
- Implements ImageSource class for single-use image data with automatic caching
- Adds Image component with streaming JS interop and CSS-driven loading states
- Provides comprehensive test coverage including unit tests and E2E scenarios
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/Components/Web/src/Image/ImageSource.cs |
Core image source model with stream and byte array constructors |
src/Components/Web/src/Image/Image.cs |
Main Image component implementation with rendering and lifecycle management |
src/Components/Web.JS/src/Rendering/BinaryImageComponent.ts |
TypeScript implementation for browser-side streaming and caching |
src/Components/Web.JS/src/GlobalExports.ts |
Exports BinaryImageComponent to global Blazor namespace |
src/Components/Web/test/Image/ImageTest.cs |
Unit tests for Image component functionality |
src/Components/test/E2ETest/Tests/ImageTest.cs |
End-to-end integration tests |
src/Components/test/testassets/BasicTestApp/ImageTest/ImageTestComponent.razor |
Test component for E2E scenarios |
src/Components/Web/src/PublicAPI.Unshipped.txt |
Public API surface additions |
src/Components/test/testassets/BasicTestApp/_Imports.razor |
Adds namespace import for test app |
src/Components/test/testassets/BasicTestApp/Index.razor |
Adds test component to navigation |
src/Components/test/testassets/BasicTestApp/BasicTestApp.csproj |
Adds project reference |
…aspnetcore into roland/image-component
Image Component
Summary
This PR introduces an Image component that renders images from non-HTTP sources (bytes or streams) with streaming JS interop and optional browser-side caching.
Features
DotNetStreamReference
for efficient streaming from .NET to JS--blazor-image-progress
--blazor-image-progress
for simple progress UI.API surface
Implementation
src/Components/Web/src/Image/Image.cs
src/Components/Web/src/Image/ImageSource.cs
src/Components/Web.JS/src/Rendering/BinaryImageComponent.ts
src/Components/Web/test/Image/ImageTest.cs
src/Components/test/testassets/BasicTestApp/ImageTest/ImageTestComponent.razor
src/Components/test/E2ETest/Tests/ImageTest.cs
Performance considerations
Related to -> #25274