Add ability to build responsive image styles in style guide#982
Add ability to build responsive image styles in style guide#982dipakmdhrm wants to merge 5 commits intomainfrom
Conversation
44e1ce5 to
08472dc
Compare
08472dc to
8dba918
Compare
| * @return array | ||
| * A render array for a <picture> element. | ||
| */ | ||
| private function buildResponsiveImage(array $image_dimensions, string $id = '', string $id_type = 'id', string $alt = ''): array { |
There was a problem hiding this comment.
stringshould normally be replaced with an enum- Can we call an actual responsive image, like used in the Themetrits / PEVB, instead of building one ourselves?
There was a problem hiding this comment.
stringshould normally be replaced with an enum
I've created enum for $id_type. $id and $alt can have any value, so keeping those as string.
- Can we call an actual responsive image, like used in the Themetrits / PEVB, instead of building one ourselves?
@amitaibu PEVB uses drupal media/image entity to build responsive images. But shouldn't we avoid Drupal entities in StyleGuideController (to avoid any database dependency and just using placeholder data)?
There was a problem hiding this comment.
I'm assuming there's a low level method that recieves a file, and creates the image style from it. Can you check that please
There was a problem hiding this comment.
@amitaibu To create a responsive image we use:
[
'#theme' => 'responsive_image',
'#uri' => $file_uri,
]
The file uri needs to be from a file stream in Drupal's local filesystem i.e. either public:// or private://.
A file in modules is in neither such stream. We'll need to temporarily copy file directly to public:// to build it's image styles, which will copy a new file on every /style-guide page request (or we'll need to hardcode a filename for public://)
We do have an alternative. We can create a custom stream wrapper for style guide module server_style_guide:// which can process files from web/modules/custom/server_style_guide/images/ to create responsive image styles.
I'd recommend this option as we have responsive images in most of our components and currently style guide displays static images for all of them.
2458c7a to
9499e8e
Compare
Replaces the html_tag-based <picture> implementation with Drupal's responsive_image theme. Adds a StyleGuideStream (server-style-guide://) read-only stream wrapper pointing to the module's images/ directory, allowing image styles to process module-bundled files without copying them to public://. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update:
|
Add accordion paragraph with three FAQ items covering DDEV setup, PEVB pattern explanation, and running automated tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
#981
Update:
server_theme