Add Field Widget Actions (FWA) support for text-to-image media generation on the media_library_widget for core Image media
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3566583. -->
Reported by: [marcus_johansson](https://www.drupal.org/user/385947)
Related to !1096
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>[One-line status update for stakeholders]<br>
<strong>Short Description: </strong>Add Field Widget Actions (FWA) support for text-to-image media generation on the media_library_widget for core Image media.<br>
<strong>Check-in Date: </strong>MM/DD/YYYY<br>
[/Tracker]</p>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Editors often need to create images while editing content, and text-to-image generation is a common AI workflow that fits well with Media Library usage. Currently, the <code>media_library_widget</code> does not provide an in-widget way to trigger AI Automators that generate an image and create a core Image Media entity from it.<br>
This issue proposes adding Field Widget Actions (FWA) support for text-to-image media generation on the <code>media_library_widget</code> for core Image Media entities, using <code>modules/ai_automators/src/Plugin/FieldWidgetAction/Email.php</code> as reference implementation. The implementation requires the core Media Library module for the widget integration, and the text-to-image module for the generation capability.<br>
A straightforward way to test this is to configure an AI Automator that takes a text prompt and generates an image, then use the FWA on the Media Library widget to create an Image Media entity and attach it to the field in the same edit form.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<ul>
<li>Add a new FWA plugin for the <code>media_library_widget</code> that triggers the text-to-image media generation workflow, modeled after <code>modules/ai_automators/src/Plugin/FieldWidgetAction/Email.php</code>.</li>
<li>Ensure the FWA creates a core Image Media entity from the generated image and returns it to the widget selection so it is attached to the field correctly.</li>
</ul>
<p>- <strong>This issue was created with the help of AI</strong></p>
> Related issue: [Issue #3573429](https://www.drupal.org/node/3573429)
> Related issue: [Issue #3508503](https://www.drupal.org/node/3508503)
> Related issue: [Issue #3574611](https://www.drupal.org/node/3574611)
issue