Loading
feat: #3631526 Add a "Generate media with AI" button to the media overview
Issue: #3631526 "Initialize the AI Media module"
Chunk 10 of the UX and integration plan (20 October 2026): the "Generate media with AI" local action (plan section 3, option (b)).
Depends on !16 (closed) (3631526-settings-order), which depends on !15 (closed) to !8 (closed) and !6 (merged). Until those merge, this diff includes them; the change of this MR is its last commit.
What changed
- A local action Generate media with AI on
/admin/content/media, beside core's Add media. - Shown only to users with Generate media with AI and at least one AI media type they can create that is offered and set up (the same checks as the generator itself). Cached per permissions, with the media type list, AI Media and AI settings tags.
- With one such type it opens that type's generator on core's Add media page (from !10 (closed)); with more, it opens core's Add media list filtered to AI types (
/media/add?ai=1, through apreprocess_entity_add_listfilter that only applies to that route and query). - No new page: the action's route (
/admin/content/media/generate) checks access and redirects to core's routes. - Docs and a new e2e feature.
How it was tested
- Plain Drupal 11.4 (
aimplan1), headless Firefox:- Content editor: the action is shown; it opens
/media/add?ai=1, listing the three AI types only. - Media author (no AI permission) and a user with "create ai_image media" but no AI permission: no action, the route is denied.
- The same user with the AI permission (one usable AI type): the action opens
/media/add/ai_imagewith the generator. With that type's provider removed, the action disappears.
- Content editor: the action is shown; it opens
- axe-core 4.10.2: the filtered chooser has 0 violations in Claro, Gin and Default Admin at 1440 and 1920. The media overview has 0 in Gin; in Claro (
#edit-submitcontrast, the views Filter button) and Default Admin (listitemon the action links) axe reports one issue each, and the same issue appears on that page without this action (checked as the media author), so it is core's or the theme's. - Varbase E2E, Firefox:
11-01-01-generate-action(2 scenarios) passes. - phpcs (Drupal, DrupalPractice), phpstan level 1, cspell, eslint, stylelint: clean.
Not tested
- The one-type redirect in the e2e suite (the fixtures give every editor several AI types); checked by hand as above.
- Navigation's Create menu: core no longer adds media links there (change record 3581445); nothing added.
- Mobile widths (out of scope).
AI-Generated: Yes. Written with Claude Code (Claude Opus 5.5) under the Drupal AI policy; tested by the author before submission.
Checkpoints:
- File an issue
- Addition/Change/Update/Fix
- Testing to ensure no regression
- Automated unit testing coverage
- Automated functional testing coverage
- UX/UI designer responsibilities
- Readability
- Accessibility
- Performance
- Security
- Developer Documentation
- User Guide Documentation
- Reviewed by human
- Code review by maintainers
- Full testing and approval
- Credit contributors
- Review with the product owner
- Release notes snippet
- Release