Allow attachments in media processor

Created on 22 May 2025, 17 days ago

Problem/Motivation

Libraries are not attached to rendered media tokens.

Steps to reproduce

- Install Drupal 11 standard profile
- Install modules patternkit_example, patternkit_media_library, layout_builder
- Configure a content type to use Layout Builder
- On /admin/config/development/settings, enable "Do not cache markup" and "Twig development mode" (this makes debugging easier)
- Create a node. On that node's Layout tab, insert block of type "[Patternkit] Media image embed".
- Select an image for that block (or upload new one).
- Save the layout.
- Inspect the image element. Notice that the Twig template rendering that image is core/modules/system/templates/image.html.twig
- Edit that Twig template. Add this line, to attach a new Claro library: {{ attach_library('claro/form-two-columns') }}
- Reload the node's page.
- Inspect the page source. Expect to find reference to core/themes/claro/css/layout/form-two-columns.css. However, you won't see it because Patternkit's media processor does not allow attachments to "bubble up" to the render system.

Proposed resolution

See proposed patch.

When applied, you should see the attached library's assets in the page source (e.g., form-two-columns.css from the above example).

Remaining tasks

Write tests?

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

9.1

Component

Module Core

Created by

🇺🇸United States krisahil

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024