feat: add mobile image variant sources to pictures#2433
Draft
ArnaudLigny wants to merge 6 commits into
Draft
Conversation
Introduce configurable mobile image variants (`mobile_suffix` and `mobile_media_query`) for both page body parsing and layout image rendering. The image pipeline now auto-detects mobile sibling assets, generates responsive `<source>` entries (including format conversions/fallbacks), and prepends them in `<picture>` output alongside dark-mode variants. Integration fixtures/tests were updated with a mobile logo asset and assertions for media/source output ordering.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for mobile-specific image variants (e.g., image.mobile.png) so Cecil can emit <picture> elements containing additional <source> entries targeting mobile via a configurable media query.
Changes:
- Added
mobile_suffixandmobile_media_queryconfiguration for both Markdown-rendered images and Twightml()rendering. - Implemented mobile-variant path detection and
<source>attribute generation for responsive/format variants. - Extended integration tests + fixtures to validate mobile variant
<source>output.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
config/default.php |
Adds default configuration options for mobile image variants (pages + layouts). |
src/Asset/Image.php |
Implements mobile-variant path building and <source> attribute generation. |
src/Converter/Parsedown.php |
Detects/caches mobile variant sources and injects them into Markdown-generated <picture>. |
src/Renderer/Extension/Core.php |
Emits mobile <source> elements when rendering images via Twig extension. |
tests/fixtures/website/config.yml |
Enables mobile variant settings in the integration test fixture site. |
tests/IntegrationTests.php |
Asserts generated HTML contains the expected mobile variant <source> and media query. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
This pull request adds support for mobile image variants throughout the codebase, allowing the system to automatically detect and serve mobile-specific image files (e.g.,
image.mobile.png) using the<picture>element and appropriate media queries. The changes include configuration options for mobile variants, logic to generate mobile<source>elements, and tests to verify the new functionality.Support for mobile image variants:
mobile_suffixandmobile_media_queryconfiguration options to bothconfig/default.phpandtests/fixtures/website/config.yml, enabling specification of mobile image variants and their associated media queries. [1] [2] [3] [4]buildMobileAssetPathandbuildMobileSourceAttributesmethods insrc/Asset/Image.phpto construct and handle mobile image variant paths and<source>attributes for responsive images. [1] [2]Rendering and parsing enhancements:
src/Converter/Parsedown.phpto detect mobile image variants, cache their source attributes, and inject them into the<picture>element alongside dark variants, ensuring correct rendering in markdown. [1] [2] [3] [4] [5]src/Renderer/Extension/Core.phpto build and include mobile<source>elements in the HTML output for images, using the new configuration options and logic. [1] [2]Testing:
tests/IntegrationTests.phpto verify that mobile variant sources are present in the generated HTML with correct media attributes and file paths.