'Search Wordpress media with Javascript

For testing purposes I want to search through the media of the featured image in Wordpress. But it seems I can't activate the search through a JavaScript action.

The search DOM on the admin page is:

<input type="search" placeholder="Search media..." id="media-search-input" class="search">

I can change the value of the input field with:

// input text string
document.getElementById('media-search-input').value = "test string";

After changing the input value, no search is being done. I guess I have to trigger the search somehow, But I don't know how?

It seems I can't trigger the search with .click(), .focus() or .blur(). There's also no button to hit because WP has a live search functionality.



Solution 1:[1]

Dug around and found this:

wp.media.frames.browse.state().get('library')._requery(true)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 haykuro