perf: add lazy loading and dynamic alt text to ImageCard#1336
Conversation
- Added loading="lazy" to the image tag inside ImageCard to prevent eager loading of off-screen media. - Replaced hardcoded 'Sample Title' alt text with dynamic filename falling back to 'Image'.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe ChangesDynamic alt text in ImageCard
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
This PR addresses two performance and accessibility issues in the
ImageCardcomponent of the frontend gallery (frontend/src/components/Media/ImageCard.tsx):loading="lazy"to the main<img />tag insideImageCardto defer the loading of off-screen media. This prevents the browser from aggressively downloading all image files on mounting large grids, significantly saving initial network bandwidth and memory overhead.'Sample Title'alt text with a dynamic value using the image metadata name (image.metadata?.name), falling back to the filename extracted from its path (image.path), and defaulting to'Image'.Closes #1326
Summary by CodeRabbit