php - Wordpress Media Library in plain javascript
I'm working with wordpress and I'm creating a theme for myself. I want to use the wordpress media library in the admin panel. So after some searching I found this page: https://codex.wordpress.org/Javascript_Reference/wp.media
There are multiple tutorials to add this media library with jQuery, but I would like to do it in a plain javascript way. I've no trouble converting the jQuery to javascript except this piece of code:
// When an image is selected in the media frame...
frame.on( 'select', function() {
// Removed unrelevant code
});
Ive tried the following things:
frame.select = function(){};
frame.onselect = function(){};
frame.addEventListener('select',function(){});
None of them are working, I get an error on the last one:
frame.addEventListener is not a function
So I hope I can get some help from here. I love everyone trying to help, but I don't want to hear: "use jQuery". The choice for not using jQuery is one I made on purpose.
StefanJanssen