Skip to content

Media: Try an experimental media folders prototype - #86414

Draft
andrewserong wants to merge 7 commits into
trunkfrom
try/media-folders-prototype
Draft

andrewserong wants to merge 7 commits into
trunkfrom
try/media-folders-prototype

Conversation

@andrewserong

@andrewserong andrewserong commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Registering a custom wp_media_folder taxonomy for attachments
  • Exposes a UI in the media inserter for adding folders, browsing by folders, adding to folders
  • Exposes a UI in the Dynamic Gallery so that you can choose a folder to auto-populate a gallery block dynamically from a folder

Why?

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

  • Make sure sorting and filtering is working correctly (this might require updates to the attachments REST API in order to handle sorting by folder?)
  • Audit which screens still need additional handling to work well with folders
  • Consider which core screens we do want to expose by default, and which should be hidden to begin with
  • Consider the media editor and how it should handle assigning folders

Testing Instructions

  1. Switch on the experiment
image
  1. Open up a post or page
  2. Go to the media inserter and you should see an extra dropdown for folders now. Again, this is not the final UX! This has just been hacked in there for now to try out the idea
  3. You should be able to add additional folders with the + button, and add to a folder using the button at the bottom of the sidebar
  4. Add a Gallery block and select to use a folder. Try selecting one of the folders to populate the gallery

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:

Core media editor screen Core taxonomy screen
image image

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

@andrewserong andrewserong self-assigned this Nov 6, 2026
@andrewserong andrewserong added [Feature] Media Anything that impacts the experience of managing media [Type] Experimental Experimental feature or API. labels Nov 6, 2026
@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] Block library /packages/block-library [Package] Block editor /packages/block-editor labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

📦 Bundle size

Size Change: +4.44 kB (+0.05%)

Total Size: 8.64 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 546 kB +1.29 kB (+0.24%)
build/scripts/block-library/index.min.js 428 kB +2.58 kB (+0.61%)
build/scripts/editor/index.min.js 569 kB +458 B (+0.08%)
build/styles/block-editor/style-rtl.css 20.1 kB +28 B (+0.14%)
build/styles/block-editor/style-rtl.min.css 17.1 kB +26 B (+0.15%)
build/styles/block-editor/style.css 20.1 kB +29 B (+0.14%)
build/styles/block-editor/style.min.css 17.1 kB +28 B (+0.16%)

bd0b8a4 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric b26ee94 trunk % Change
timeToFirstByte 34.15 ms +21.08% -2.49% 34.25 ms +20% -4.96% -0.29%
largestContentfulPaint 60 ms +6.67% -6.67% 60 ms +6.67% -6.67% 0%
lcpMinusTtfb 24.95 ms +9.82% -13.23% 24.4 ms +12.7% -15.78% 2.25%
wpBeforeTemplate 17.78 ms +22.16% -1.74% 18.01 ms +18.55% -5.05% -1.28%
wpTemplate 13.25 ms +13.74% -2.79% 12.93 ms +10.9% -1.7% 2.47%
wpTotal 31.16 ms +21.92% -2.57% 31.27 ms +18.36% -4.8% -0.35%
wpMemoryUsage 7.72 MB +0% -0% 7.68 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric b26ee94 trunk % Change
timeToFirstByte 29.45 ms +7.98% -4.24% 28.2 ms +8.69% -2.66% 4.43%
largestContentfulPaint 56 ms +3.57% -7.14% 52 ms +7.69% -0% 7.69%
lcpMinusTtfb 24.45 ms +9.61% -2.25% 24.2 ms +2.48% -2.27% 1.03%
wpBeforeTemplate 15.98 ms +16.83% -2.07% 15.62 ms +4.61% -2.11% 2.3%
wpTemplate 10.08 ms +6.35% -2.08% 10.22 ms +2.74% -8.61% -1.37%
wpTotal 26.58 ms +9.48% -3.5% 25.66 ms +7.21% -2.46% 3.59%
wpMemoryUsage 6.41 MB +0% -0% 6.37 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric b26ee94 trunk % Change
mediaProcessingJpeg 224.13 ms +1.95% -0.93% 221.76 ms +1.47% -1.57% 1.07%
mediaProcessingAvif 3654.35 ms +0.91% -1.47% 3712.71 ms +0.43% -0.57% -1.57%
mediaProcessingJpegToAvif 2558.53 ms +0.12% -1.77% 2499.4 ms +0.31% -0.59% 2.37%

media-upload

Metric b26ee94 trunk % Change
jpegUploadProcessing 1454.66 ms +0.91% -0.98% 1418.82 ms +0.77% -0.69% 2.53%
pngUploadProcessing 199.27 ms +2.03% -1.03% 186.04 ms +3.6% -5.63% 7.11%
largeJpegUploadProcessing 1441.67 ms +1.27% -1.31% 1421.35 ms +1.07% -0.71% 1.43%
multipleImageUploadProcessing 1492.6 ms +1.25% -1.36% 1480.74 ms +0.54% -1.18% 0.8%

post-editor

Metric b26ee94 trunk % Change
serverResponse 397.19 ms +6.27% -4.29% 416.21 ms +1.61% -8.64% -4.57%
firstPaint 449.28 ms +9.3% -6.72% 410.47 ms +5.61% -3.29% 9.46%
domContentLoaded 822.78 ms +4.54% -1.56% 829.86 ms +1.41% -0.81% -0.85%
loaded 824.01 ms +4.52% -1.55% 830.99 ms +1.4% -0.8% -0.84%
firstContentfulPaint 468.62 ms +9.47% -1.3% 465.98 ms +3.49% -1.04% 0.57%
firstBlock 2138.09 ms +8.19% -1.89% 2120.15 ms +0.52% -1.99% 0.85%
type 17.91 ms +8.15% -9.94% 17.51 ms +4.91% -7.6% 2.28%
typeWithoutInspector 18.24 ms +5.7% -17.43% 17.26 ms +2.95% -7.71% 5.68%
typeWithTopToolbar 23.66 ms +6.38% -8.24% 22.92 ms +7.11% -7.46% 3.23%
typeContainer 8.22 ms +9.73% -10.46% 8.47 ms +7.91% -7.44% -2.95%
focus 125.77 ms +10.65% -2.24% 122.18 ms +6.61% -4% 2.94%
firstFocus 296.99 ms +0% -0% 256.61 ms +0% -0% 15.74%
selectAll 363.3 ms +4.58% -3.9% 360.14 ms +2.63% -2.49% 0.88%
undo 30.07 ms +6.78% -5.15% 31.65 ms +9.86% -8.21% -4.99%
listViewOpen 82.28 ms +12.83% -10.38% 79.27 ms +6.67% -12.92% 3.8%
inserterOpen 45.36 ms +3.37% -7.74% 42.17 ms +20.2% -4.79% 7.56%
inserterHover 13.04 ms +7.82% -2.61% 12.43 ms +10.22% -7.48% 4.91%
inserterSearch 8.62 ms +13.81% -8.82% 8.1 ms +21.48% -5.31% 6.42%
loadPatterns 718.79 ms +1.61% -5.68% 731.75 ms +1.99% -2.3% -1.77%
wpTotal 387.66 ms +6.34% -4.43% 406.25 ms +1.7% -8.83% -4.58%
wpMemoryUsage 14.77 MB +0% -0% 14.74 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric b26ee94 trunk % Change
serverResponse 487.55 ms +0.26% -6.02% 480.68 ms +1.03% -7.87% 1.43%
firstPaint 484.81 ms +7.38% -12.1% 419.88 ms +7.73% -2.22% 15.46%
domContentLoaded 870.17 ms +5.85% -1.83% 855.66 ms +1.55% -1% 1.7%
loaded 871.23 ms +5.87% -1.77% 856.88 ms +1.53% -0.98% 1.67%
firstContentfulPaint 497.9 ms +10.54% -2.09% 485.32 ms +1.38% -0.75% 2.59%
firstBlock 2683.41 ms +2.81% -1.02% 2648.47 ms +0.41% -0.66% 1.32%
type 19.47 ms +8.17% -7.29% 19.11 ms +15.86% -8.01% 1.88%
navigate 127.3 ms +2.67% -1.78% 123.43 ms +1.2% -2.05% 3.14%
loadPatterns 1440.03 ms +8.48% -9.39% 1482.46 ms +4.4% -2.83% -2.86%
loadPages 993.09 ms +3.07% -1.36% 980.89 ms +2.29% -1.93% 1.24%
wpTotal 477.9 ms +0.27% -6.14% 470.84 ms +1.05% -8% 1.5%
wpMemoryUsage 12.79 MB +0% -0% 12.75 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

bd0b8a4 Run

@padams

padams commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

👍 for the use of an image taxonomy!!

@padams

padams commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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 wp_media_folder instead of code specific to the modal. My use case is PhotoPress, a photography plugin. It adds several image taxonomies, such as genre, keywords, camera and lens, and users want to combine them as filters. I'm happy to change either PR to fit what the folders work needs.

@ramonjd

ramonjd commented Nov 9, 2026

Copy link
Copy Markdown
Member
Screenshot 2026-11-09 at 11 59 49 am

This is so cool. I love that we can use folders to drive galleries.

This would be a great experiment to have in Gutenberg early so we can get feedback.

Thank you for driving this!

wp_media_folder

Also +1 on the separate taxonomy, so we don't have to worry about all the attachment PT exceptions/peculiarities.

Whenever we get around to it, wondering how we could tackle this. E.g., PRs for

  • the taxonomy
  • the add to filter UI
  • gallery

Hmm also thinking about permissions... same as categories?

Action Who
Create, rename, delete a folder Editors and Admins (manage_categories)
Add or remove an image Anyone who can edit that image

@padams

padams commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

I have PRs (above) for getting any/all image taxonomies to show up as filters in the experimental data views media modal.

@fcoveram

Copy link
Copy Markdown
Contributor

I haven't thought about how we can level up the UX, but overall the idea is great ✨

@andrewserong

Copy link
Copy Markdown
Contributor Author

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 🙂

@andrewserong
andrewserong force-pushed the try/media-folders-prototype branch from f537f0d to 2bee5c5 Compare November 11, 2026 04:43
andrewserong and others added 7 commits November 16, 2026 15:19
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

This branch has not been deployed

No deployments
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 [Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Editor /packages/editor [Package] Fields /packages/fields [Type] Experimental Experimental feature or API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants