-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Try: a generic Edit config for media
#73590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Braindumping some thoughts I have: This is a challenge due to how we set up fields as a standalone objects.
|
How can this be the case when we will need to pass functions like Additionally by looking the |
|
@ntsekouras Yeah, the current state of this PR isn't. That's the core question I'd like to answer: how do we make this reusable and serializable? The API already enables us to provide a custom Edit, but is there a better way? Potential ideas to follow-up:
// Pass custom Edit controls:
{
id: 'media',
type: 'media,
Edit: 'wpMedia'
}
// or define custom field types:
{
id: 'media',
type: 'wpMedia,
}Then, separately, there's an API to register either the |
|
Thanks for digging into this idea! I think a challenge here is that ideally the DataViewsPicker (or whatever the picker is) is decoupled from the field. As an example, there's a new media library modal experiment in Gutenberg here (the code lives in
So it should be possible for folks to use either the new media library, or hook into the existing media library, and for this to be separate from the fields themselves. Another detail is that the picker itself will grow in complexity over time, handle uploads, have its own fields, etc, etc (media-specific fields are being explored in: #73071) I guess my question for this API is: how do we offer the flexibility that the picker can live elsewhere (and have a common API), but the media field gets to define a common button that invokes that picker. I think it's more the button, displaying a tiny preview of the selected media / clearing media, etc, that's what belongs in the DataViews/DataForm package, whereas the media picker itself should probably live elsewhere. |
|
In general if we want a generic media edit control we need to write a media upload component ourselves, which is quite complex with all the things such a component needs. I think most of the complexity is not around the picker, but the uploading and handling of images and I don't think we need to prioritize this, since our immediate needs are for WP media fields.
That was what I had understood we wanted TBH and even if we decouple the That's why I think my PR for the |
Very good point 👍
I think I'm with you there — this PR is a good exploration, but it raises a lot of questions about API design and where extensibility points could or should live. I like your idea to focus on the initial step (get a more common component happening within |
|
I'm going to close this one. I'm not convinced this is ready to tackle this way, other approaches we are already investigating would be better. |

This is an incomplete prototype, it doesn't deal with adding new data, or update selection, etc. It's here to surface challenges with direction.
What?
This PR experiments with having a generic Edit config for the
mediacontrol.Why?
By having a configurable generic Edit config:
How?
Creates a new
mediaEdit control that takes some config. That config is all the properties ofDataViewsPicker:Screen.Recording.2025-11-26.at.14.52.23.mov
Challenges / what's next?
Testing Instructions
Run the local storybook (
npm install && npm run storybook:dev) and go to "DataViews > Field types > media" story.