[Feature][PoC]: Issue 325 | Experimental Media Editor | AI Alt Text#446
Draft
TylerB24890 wants to merge 3 commits intoWordPress:developfrom
Draft
[Feature][PoC]: Issue 325 | Experimental Media Editor | AI Alt Text#446TylerB24890 wants to merge 3 commits intoWordPress:developfrom
TylerB24890 wants to merge 3 commits intoWordPress:developfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #446 +/- ##
=============================================
- Coverage 66.90% 66.75% -0.16%
- Complexity 907 910 +3
=============================================
Files 59 59
Lines 4699 4710 +11
=============================================
Hits 3144 3144
- Misses 1555 1566 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dkotter
requested changes
Apr 20, 2026
…of smaller function level ones. Remove wrapping div from DecorativeNotice.
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.
What?
See #325
This PR integrates the AI Alt Text generation experiment into the new experimental Media Editor in Gutenberg.
It is intended as a Proof of Concept/MVP implementation only.
Related:
Why?
Currently all AI experiments only target the existing core media library and modals. This is sufficient for the time-being, but as WordPress continues to evolve its important that the AI features available in the legacy media UI are also available in the upcoming media UI.
How?
The new Media Editor does not currently provide any filters or Slot/Fill components for extending the field output. This means we are not able to hook into the media editor fields and add new components within the existing fieldset. We must register our field separately with
registerEntityFieldto theattachmentpost type. By default this appends the registered fields to the bottom of the form, with no way to control the render order.To ensure the Alt Text field and the "Generate" button are rendered together, we're overriding the core Alt Text input and rendering it with a
<Button />to trigger the Alt Text generation. This moves the Alt Text field to the bottom of the UI, but keeps the "Generate" button inline/next-to the Alt Text<TextareaControl />component.Additionally, because
registerPostTypeSchemaruns asynchronously fromusePostFieldswe can't accurately determine whichFieldcomponent will be registered first. Like all objects, the last reference will take priority, meaning if the coreFieldis registered after our customField, it will override our override.To get around this, we are subscribing to the
postTypestate and re-registering theFieldonce the state changes to theattachmentpost type with a100msdelay. This ensures our customField(andButton) are registered after the coreFieldand therefore taking priority in the render. Subscribing to thepostTypestate ensures this re-register only happens once, as thepostTypeis set only once.Use of AI Tools
media-editorpackage.registerPostTypeSchemaandusePostFieldsSuggested Next Steps
media-editorpackage field output allowing us to hook into and modify theattachmentpost type fields directly (rather than overriding with asetTimeout)Fieldcomponent in its current position in the form.ImageGenerationexperiment into the new Media Editor.media-editorpackage.Testing Instructions
Screenshots or screencast
Note: Notice the alt text has been moved to the bottom of the UI with the Generate button. This is a result of not having any existing hooks to the Field rendering.
Changelog Entry
Added - New feature.