feat(core): opt-in image dimension (CLS) validation#143
Merged
Conversation
Adds checks.images.dimensions. Reusing the existing image detection, it flags CMS image fields that expose no usable width/height and emits CMS-IMG-DIMENSIONS (warning) - a common cause of layout shift (CLS), since the app cannot reserve space before the image loads. Understands the common provider dimension shapes (width/height, dimensions.*, media_details.*, file.details.image.*, and Sanity asset.metadata.dimensions.*). Off by default; adds an images report group for the new code in HTML and JUnit output.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What
Adds
checks.images.dimensions. Reusing the existing per-provider image detection, it flags CMS image fields with no usable width/height and emitsCMS-IMG-DIMENSIONS(warning).Recognizes the common provider dimension shapes:
width/height,dimensions.{width,height}(Prismic),media_details.{width,height}(WordPress),file.details.image.{width,height}(Contentful), andasset.metadata.dimensions.{width,height}(Sanity).Why
Images without intrinsic dimensions are a top cause of layout shift (CLS), a Core Web Vital on the 2026 SEO checklist - the app can't reserve space before the image loads.
Off by default
checks.imagesstays a master toggle (falsedisables the alt check); the object form{ dimensions: true }opts into this. Off by default since some providers keep dimensions out of band.How verified
{ dimensions: true }flags a dimensionless image; width/height anddimensions.*shapes pass; zero width/height is flagged.pnpm verifygreen (219 tests).Refs improvements/37.