Insert HTML markup to the content from the Media Frame + Controller and States


How do I insert HTML markup in the content from the Media Frame. ( Media Modal or Media Library, whichever the preferred term is. )

I can’t find a lot of documentation in the WordPress Codex, other than this;

So I’ll be using the same terms for the modal areas, as they are stated in this Google Doc (I think it’s by Eric Andrew Lewis.)

I’m trying to insert media from a custom router-tab in the media frame.
But I have no idea how to take “the stuff” (HTML markup) from the media frame and place it into the content.

My setup is based on the Github repo custom_media_menu.js created by Fab1en.
( ) ( There is no license so I won’t just copy it. )

The first code-block you encounter extends on and has a property called customAction that’s called when the insert button is pressed. But I don’t know which function to use to place the customAction stuff in the content and replacing the Gutenberg upload placeholder.

From looking around on the Stack-forums, I get the feeling that is has something to do with state.
But when reading the Backbone JS documentation Controller and States isn’t mentioned.
So that must be something added in the WordPress implementation.
I’ve been reading some of the core implementation, but I don’t find it obvious whats going on.

Any hints on what to read up on and where to go next, will be much appreciated.

Mads Hansen 4 months 0 Answers 16 views 0

Leave an answer