Skip to content

Media Editor Route Experiment: Override media edit links to point to the new experimental media editor - #81559

Merged
andrewserong merged 2 commits into
trunkfrom
update/media-editor-route-experiment-to-hook-edit-links
Aug 13, 2026
Merged

Media Editor Route Experiment: Override media edit links to point to the new experimental media editor#81559
andrewserong merged 2 commits into
trunkfrom
update/media-editor-route-experiment-to-hook-edit-links

Conversation

@andrewserong

@andrewserong andrewserong commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Part of:

What?

Override edit post links, i.e. those used in the core media library to point to the experimental media editor, when the "Media Editor (Route)" experiment is active.

Why?

While the media editor is very far from being feature complete (see the parity gaps in #72734) to help those of us working on this to test out the editor and get a feel for those gaps, this PR proposes wiring up the editor so that it's part of the flow of editing and managing media (when the experiment is on).

⚠️ there are very big gaps in behaviour between the core editor and this one, for example there's currently no way to save changes in this flow 😄. Fixes and filling in gaps will be for follow-ups.

How?

  • Filter on 'get_edit_post_link' and point to the URL for the experimental new media editor.
  • Also add a redirect to the new screen in case folks attempt to access the classic screen via direct url (I can remove this from the PR if it feels like too much for now)
  • JS change: in the media editor code add a scope prop that allows a consumer to pass in a custom scope for the editor — this could arguably be its own PR but while testing this PR out, I noticed that in the route-based approach if I'd had the sidebar closed in the media editor modal closed, then it'd be closed in the route-based editor. I think these should be separate scopes and we really want this editor to default to the sidebar being open.

Testing Instructions

Enable the Media Editor (Route) experiment:

image

Go to the Media library screen in wp-admin and click on an image or its "Edit" link:

image

This should navigate you to the new media editor screen, instead of the core screen.

Then, disable the experiment and double-check that when you use the above link it takes you back to the old screen.

Screenshots or screencast

2026-08-13.14.42.53.mp4

Use of AI Tools

Claude Code (Opus 5) to generate the change, reviewed and tested by me.

…the experimental media editor route

Wire the route-based media editor into the places WordPress sends people to
edit an attachment, so the experiment can be used in place of the classic
Edit Media screen rather than only reached by hand-typed URL.

- Filter `get_edit_post_link` for attachments, so the Media Library list
  table, the media modal's "Edit more details" and "Edit Image" links, and
  the admin bar navigate straight to the route with no redirect hop.
- Redirect the classic screen on `load-post.php` to catch bookmarks and
  hard-coded links. GET and `action=edit` only, so the save handlers run
  untouched, and bail on missing capability or a trashed post so post.php
  keeps rendering its own errors.
- Gate both on `upload_files`, which the media editor page requires but
  `edit_post` does not imply — a contributor can own an attachment without
  being able to upload, and would otherwise be sent to a screen that
  refuses them.
- Give `MediaEditor` a `scope` prop so each frame keeps its own persisted
  details-sidebar visibility. The modal and the route previously shared one
  preference, so collapsing the sidebar in the modal permanently defeated
  `isActiveByDefault` on the route.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@andrewserong andrewserong self-assigned this Aug 13, 2026
@andrewserong andrewserong added [Feature] Media Anything that impacts the experience of managing media [Type] Experimental Experimental feature or API. labels Aug 13, 2026
@github-actions

Copy link
Copy Markdown

Size Change: +24 B (0%)

Total Size: 7.72 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 530 kB +24 B (0%)

compressed-size-action

@andrewserong
andrewserong marked this pull request as ready for review August 13, 2026 04:47
@andrewserong
andrewserong requested a review from ramonjd August 13, 2026 04:47
@github-actions

github-actions Bot commented Aug 13, 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. You can also manually ask me to refresh this list by adding the props-bot label.

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: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>

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

@ramonjd ramonjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a safe change. load.php is gated behind the experiment.

I tested manually and it works as described.

@andrewserong

Copy link
Copy Markdown
Contributor Author

Thanks for the review! 🙇

@andrewserong
andrewserong merged commit 150cd6d into trunk Aug 13, 2026
49 checks passed
@andrewserong
andrewserong deleted the update/media-editor-route-experiment-to-hook-edit-links branch August 13, 2026 05:38
@github-actions github-actions Bot added this to the Gutenberg 23.9 milestone Aug 13, 2026
ramonjd added a commit that referenced this pull request Aug 21, 2026
None of the three entries were breaking. `scope` is still accepted and
still compiles; `HistoryActions` rendering nothing under a condition is
not an API change; and `MediaEditor.ImageControls` was added in #81563
and has never shipped, so no released caller can reference it.

The two that describe real API movement move to Enhancements. The
`scope` entry from #81559 goes: it described the same work the
`ComplementaryArea` line above it already covers.
ramonjd added a commit that referenced this pull request Aug 24, 2026
None of the three entries were breaking. `scope` is still accepted and
still compiles; `HistoryActions` rendering nothing under a condition is
not an API change; and `MediaEditor.ImageControls` was added in #81563
and has never shipped, so no released caller can reference it.

The two that describe real API movement move to Enhancements. The
`scope` entry from #81559 goes: it described the same work the
`ComplementaryArea` line above it already covers.
ramonjd added a commit that referenced this pull request Aug 24, 2026
None of the three entries were breaking. `scope` is still accepted and
still compiles; `HistoryActions` rendering nothing under a condition is
not an API change; and `MediaEditor.ImageControls` was added in #81563
and has never shipped, so no released caller can reference it.

The two that describe real API movement move to Enhancements. The
`scope` entry from #81559 goes: it described the same work the
`ComplementaryArea` line above it already covers.
ramonjd added a commit that referenced this pull request Aug 27, 2026
None of the three entries were breaking. `scope` is still accepted and
still compiles; `HistoryActions` rendering nothing under a condition is
not an API change; and `MediaEditor.ImageControls` was added in #81563
and has never shipped, so no released caller can reference it.

The two that describe real API movement move to Enhancements. The
`scope` entry from #81559 goes: it described the same work the
`ComplementaryArea` line above it already covers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Media Anything that impacts the experience of managing media [Type] Experimental Experimental feature or API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants