Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

conico974
Copy link
Contributor

Make sure to only use a correct DPR for avif/webp component.
PageCover now also use a srcSet

Copy link

linear bot commented Aug 4, 2025

Copy link

changeset-bot bot commented Aug 4, 2025

⚠️ No Changeset found

Latest commit: 8aa6b78

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

argos-ci bot commented Aug 4, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2 (Inspect) 👍 Changes approved 42 changed Aug 5, 2025, 8:28 AM
v2-cloudflare (Inspect) 👍 Changes approved 10 changed Aug 5, 2025, 9:01 AM
v2-vercel (Inspect) 👍 Changes approved 26 changed Aug 5, 2025, 8:36 AM

@conico974 conico974 requested a review from Copilot August 4, 2025 19:04
Copy link
Contributor

@Copilot Copilot AI left a 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

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.

1 participant