Skip to content

Alt Text Generation: Show the Generate button in the Media Editor route and modal on Gutenberg 23.3+ - #1433

Merged
dkotter merged 7 commits into
WordPress:developfrom
yogeshbhutkar:fix/alt-text-generation-media-editor
Nov 30, 2026
Merged

dkotter merged 7 commits into
WordPress:developfrom
yogeshbhutkar:fix/alt-text-generation-media-editor

Conversation

@yogeshbhutkar

@yogeshbhutkar yogeshbhutkar commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What, Why, and How?

Closes #1432

Restores the "Generate Alt Text" button in Gutenberg's Media Editor, in both the modal and the route. It also adds accessibleWhenDisabled to the button.

The legacy script overrides core's alt_text field 100 ms after detecting the modal or route, but core's fields replace it. Since Gutenberg 23.3, the modal registers its fields only once it opens, so core's registration finishes after ours. The route never sets up core/editor, so the script's route detection never fires.

On Gutenberg 24.3+, where wp_update_entity_fields() exists, the Edit part of alt_text is handed to a new @ai/alt-text-field script module that renders MediaEditorAltTextControl. This is similar to how the excerpt generation experiment handles. On older versions, the legacy script now registers its field from the core.registerPostTypeSchema action, which core fires right after registering its own fields. The timer and store subscribers are removed as they're no longer needed.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5.5
Used for: Investigating Gutenberg source and history, and drafting the legacy-path fix and this description; reviewed and tested by me.

Testing Instructions

  1. In Gutenberg → Experiments, enable the Media Editor experiment.
  2. Make sure both Media Editor (Route), and Media Upload Modal experiments under "Media" are enabled.
  3. In AI settings, enable Alt Text Generation.
  4. Modal: add an Image block, pick an image from the Media Library, and click on "Crop" button from the toolbar.
  5. Notice the "Generate Alt Text" button is now functional.
  6. Route: Navigate to Media -> Library -> Select an Image -> Click "Edit more details".
  7. Notice the "Generate Alt Text" button is now functional.

Screencast

fix.mov

Changelog Entry

Fixed - Show the Alt Text Generation button in Gutenberg's Media Editor modal and route.

Open WordPress Playground Preview

@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.57895% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.53%. Comparing base (c4666bb) to head (eb71c1e).

Files with missing lines Patch % Lines
...iments/Alt_Text_Generation/Alt_Text_Generation.php 31.57% 13 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #1433      +/-   ##
=============================================
- Coverage      85.59%   85.53%   -0.06%     
- Complexity      5091     5095       +4     
=============================================
  Files            193      193              
  Lines          18425    18443      +18     
=============================================
+ Hits           15770    15775       +5     
- Misses          2655     2668      +13     
Flag Coverage Δ
unit 85.53% <31.57%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yogeshbhutkar
yogeshbhutkar force-pushed the fix/alt-text-generation-media-editor branch from a3a82f1 to d9a23e8 Compare November 25, 2026 06:39
@yogeshbhutkar
yogeshbhutkar marked this pull request as ready for review November 25, 2026 07:37
@yogeshbhutkar
yogeshbhutkar requested a review from a team November 25, 2026 07:37
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@dkotter dkotter added this to the 1.6.0 milestone Nov 25, 2026
Comment thread packages/alt-text-field/src/index.tsx Resolved
@yogeshbhutkar
yogeshbhutkar force-pushed the fix/alt-text-generation-media-editor branch from 10efdd8 to eb71c1e Compare November 26, 2026 05:12
@dkotter
dkotter merged commit f1c6054 into WordPress:develop Nov 30, 2026
40 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alt Text Generation: Generate button missing from the Media Editor route and modal

2 participants