Add new registerInserterMediaCategory API to make media categories extensible#51542
Add new registerInserterMediaCategory API to make media categories extensible#51542ntsekouras merged 4 commits intotrunkfrom
registerInserterMediaCategory API to make media categories extensible#51542Conversation
4e66a1f to
e542fed
Compare
There was a problem hiding this comment.
What I need for docs is to export these type definitions(InserterMediaRequest, InserterMediaItem, InserterMediaCategoryLabels, InserterMediaCategory). Is there a standarized way to do that, that I'm not aware of?
Currently are docs formatter supports generating only one typedef in docs. So one way to go(if there is no standarized way) would be to augment or update our formatter to handle this use case. Another way would be to just add them as comments in the function's description, but I'd like to avoid the duplication of the types descriptions.
|
Size Change: +340 B (0%) Total Size: 1.43 MB
ℹ️ View Unchanged
|
draganescu
left a comment
There was a problem hiding this comment.
Tested this and it works as described. The code makes sense to me.
|
I've been playing around with this and it works nicely 👍 |
e542fed to
4abdad1
Compare
|
I didn't test but the code looks good to me now. 👍 |
9f77dfd to
b092365
Compare
|
Flaky tests detected in b092365. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5353817841
|
…extensible (WordPress#51542) * Add new `registerInserterMediaCategory` API to make media categories extensible * make `registerInserterMediaCategory` an action * add tests * add docs
|
@ntsekouras, I'm sorry if this is not the best place for this, but I have a question: is it possible to use this functionality to add a list of images that come not from an external source, but from a theme or a plugin directory? I wonder if this would be a nice way to provide "Theme suggested assets" that are not uploaded to the media library but are not necessarily external to the server. |
Sorry for the delayed reply. Each category has to implement a |
What?
In #44918 and #46222 we added a new media tab in the inserter and integrated Openverse respectively. Currently the media categories are stored in a private block editor setting(
inserterMediaCategories), which means they are not extensible.This PR adds a new
blockEditoraction for registering additional media categories. The used setting is preserved as a private one, so extenders can only add new categories without having any control over the core media categories.Tasks
Testing Instructions
Run the below function in dev tools console and observe the new category in inserter's media tab. The example uses the Openverse category object and just updates the names used.