Repository navigation
feat(image): add reduced-motion still variant - #2285
Merged
Merged
Conversation
When an image has a sibling with a `-static` suffix, such as hero-static.svg next to hero.svg, render it inside a <picture> whose source applies under `prefers-reduced-motion: reduce`. For a color-mode image the suffix goes before the mode, so hero-static-dark.svg pairs with hero-dark.svg. The browser selects the source, so no script runs and the animation never starts. Images without a sibling, inline SVGs and sprites render unchanged. The still image loads under img-src like the original, so strict CSP settings need no change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
✅ Deploy Preview for gethinode-demo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Collaborator
Author
|
🎉 This PR is included in version 3.46.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Summary
An image can now carry a still variant for readers who prefer reduced motion. When a file with the same base name plus a
-staticsuffix exists,assets/helpers/image-definition.htmlwraps the<img>in a<picture>whose<source>applies under(prefers-reduced-motion: reduce):hero.svgpairs withhero-static.svg. For a color-mode image, the suffix goes before the mode, sohero-dark.svgpairs withhero-static-dark.svg. Modes come frommain.modes.assets/helpers/still-sibling.htmlfollowsraster-sibling.html: page resource, then global asset, thenstatic/. Remote URLs and#anchorsprites are skipped, and a missing sibling logs nothing.<img>the image pipeline renders, including hero, card and the image shortcode, so no new argument or mod-blocks change is needed. Inline SVGs and sprites render unchanged, and so do images without a sibling.img-srcexactly like the original, with no inline script or style.Verification
pnpm testpasses: lint, color-mode tests, all five template builds, andtest-strict-images.tests/templates/layouts/_partials/tests/still-sibling.htmlcovers 9 lookup cases and 4 rendered-markup cases. It renders on the thumbnails page, so thestrict-imagesbuild also shows that a missing sibling logs no warning.HUGO_MODULE_REPLACEMENTS+--ignoreVendorPaths. Only the page with-staticsiblings changed. Headless Chrome with--force-prefers-reduced-motionshowed the still image in light and dark mode, and logged no CSP violations under the site'sdefault-src 'none'policy.🤖 Generated with Claude Code