-
Notifications
You must be signed in to change notification settings - Fork 4k
Fix image format handling and enhance PageCoverImage component #3527
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?
Conversation
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
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 fixes image format handling for AVIF and WebP formats by implementing proper DPR (Device Pixel Ratio) constraints based on Cloudflare's image transformation limits, and enhances the PageCoverImage component to support responsive images with srcSet.
- Implements DPR calculation logic to respect Cloudflare's format-specific size limits (1600px for AVIF, 1920px for WebP)
- Adds srcSet and sizes attributes to PageCoverImage components for better responsive image loading
- Refactors image size calculation in PageCover to improve efficiency and support srcSet generation
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
packages/gitbook/src/routes/image.ts | Adds format-specific size limits and DPR calculation logic for AVIF/WebP images |
packages/gitbook/src/components/PageBody/PageCoverImage.tsx | Adds srcSet and sizes attributes to img elements for responsive loading |
packages/gitbook/src/components/PageBody/PageCover.tsx | Refactors image size calculation to support srcSet generation |
Make sure to only use a correct DPR for avif/webp component.
PageCover now also use a srcSet