Repository navigation
Media: Try an experimental media folders prototype - #86414
andrewserong wants to merge 7 commits into
Conversation
🤖 PR meta 🤖📦 Bundle sizeSize Change: +4.44 kB (+0.05%) Total Size: 8.64 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
|
|
👍 for the use of an image taxonomy!! |
|
This overlaps with two PRs I opened for filtering attachments by taxonomy in the DataViews media modal:
With both PRs, the folder filter could come from registering a field for |
|
I have PRs (above) for getting any/all image taxonomies to show up as filters in the experimental data views media modal. |
|
I haven't thought about how we can level up the UX, but overall the idea is great ✨ |
Thanks @fcoveram! Any and all ideas welcome either here or on the linked issues. The goal of this PR is just to try out the ideas and see what gaps need filling (like Peter identified with the couple of PRs for taxonomy filters etc). Once we've got a sense of the overall shape here, I can start splitting out smaller PRs as @ramonjd suggested so that we can build this out in stages behind an experiment (like we've done for the media editor). I figure it's easier at this early stage to have this prototype to play with, though 🙂 |
f537f0d to
2bee5c5
Compare
Behind the new `gutenberg-media-folders` experiment, register the hierarchical `wp_media_folder` taxonomy on attachments and expose media folders to the inserter: - The editor supplies a private `inserterMediaFolders` setting (the folder terms, whether the user may create one, and a `create` function). - Every core media source maps a `folder` request param onto the REST `media-folders` filter and gains `assignToFolder`/`removeFromFolder` capabilities that keep an attachment's other folders intact. No inserter UI yet; with the experiment off nothing changes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012DJcei5UwkzseefoFGE4r7
Behind the `gutenberg-media-folders` experiment, the Media tab gains a folder dropdown beneath its search, with a "New folder" button for users who may create one. Choosing a folder filters the grid, and an empty one says so rather than reporting no results. The tab owns the selection, as it owns the search term, so a folder survives switching media type and is still there on returning to a source that has folders. A source without them ignores the filter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012DJcei5UwkzseefoFGE4r7
Each card's actions menu gains "Add to folder…", which picks a destination in the action's own modal, and, while browsing a folder, "Remove from folder". The footer swaps to an "Add to folder" picker that files a whole selection into the folder being browsed, in place of the attach button. The capabilities sit in `use-attachment-actions` beside attach and detach, since they are the same kind of thing: private to core's sources, raising their own notices, and refreshing the grid once the write lands. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012DJcei5UwkzseefoFGE4r7
Adds `core/media-folder` as a second dynamic Gallery source, so a folder assembled in the Media tab can be pointed at from a Gallery block. Unlike `core/attached-media` this source names its own content, so it is not relative to the post being rendered and resolves anywhere, templates and patterns included. The descriptors now carry that distinction as `requiresPost`, and `isAvailable` keeps the folder source hidden while the experiment is off, where the taxonomy isn't registered. The single hardcoded "Use attached images" entry button becomes one button per source, in the placeholder and in the Source panel, since an empty Gallery renders only the placeholder. A folder gallery gets a "Folder" control in the Source panel, and says what to do rather than what will appear while no folder is chosen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012DJcei5UwkzseefoFGE4r7
…ngelogs Unit tests for the folder filter's effect on the panel (the query, the footer action, the per-item actions and the empty message), for the fetch query dropping an unset argument, and for the Gallery's folder source and its availability gating. A PHPUnit test for the server-side resolver, which registers the taxonomy the way the experiment does so it exercises the real configuration — including the count callback that keeps unattached media from reporting every folder as empty. An e2e spec for the whole workflow: create a folder from the Media tab, file an image into it, take it out again, then point a Gallery at the folder and check it renders both in the editor and on the front end. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012DJcei5UwkzseefoFGE4r7
bd0b8a4 to
0aa51e8
Compare

What?
Note
The UI is really hacked in there for now, and this is largely vibe-coded. Please don't look at the code, I haven't yet! Consider this just a prototype for now as I play around with some ideas⚠️
Part of:
Try out a prototype for media folders. This prototype currently includes:
wp_media_foldertaxonomy for attachmentsWhy?
To explore both the technical and UX sides of allowing folks to categorise and organise media into folders or categories. The goal is for this to feel relatively lightweight to a user.
How?
TBD
To-do
Testing Instructions
Screenshots or screencast
Much of the default functionality in WordPress works out of the box as soon as you register the taxonomy. The UIs aren't necessarily the best, but they work. Here's a couple of screenshots where UI is exposed (or can be exposed) by default:
Here's a quick demo of the current state in the block editor, which is the bulk of the changes in this PR (e.g. media inserter and dynamic gallery block):
2026-11-06.17.30.38.mp4
Use of AI Tools
Claude Code (Opus 5.5) — this is currently vibe coded⚠️ I have not yet reviewed and likely won't for some time as this is still just a prototype to prove out the idea