- I have a custom "Stock Photos" post type.
- Images that are attached to a "Stock Photo" are given a meta key of
is_stock_photo = 1.
- I have logic that makes it so on the "Media" screen, images with that meta key are excluded from the results.
I would like to also exclude those results in the media upload frame, but only on the media screen. If you are on the stock photos custom post type, I want exactly the opposite - only stock photos appear in the media uploader.
So I have the logic to hide or show them in
pre_get_posts. But I can't identify if I am on the stock photos post type screen, or editing a page. The media uploader is driven through AJAX and so I can't check the URL and the request variables don't help identify the page either.
Here is what the default ajax call includes (plus a field from ACF, I want what they added basically):
http://example.org/wp-admin/admin-ajax.php --- action:query-attachments post_id:775 query[post_mime_type]:image query[orderby]:date query[order]:DESC query[posts_per_page]:40 query[_acfuploader]:field_57df470db0c1c query[paged]:1
I would like to inject my own, such as:
query[show_stock_photos]: (1 or 0)
I've done some research but it's all JS. WordPress documentation barely includes anything about the media uploader. All I know is the answer probably lies in the
wp.media object that is accessible in the js console, but I can't find any more clues.