How to create different media uploader frames / filter library depending on a custom action
Here is the thing. I am using the WP media uploader on the frontend. What I need is to have it behave differently depending on a certain action.
I am attaching the media in a specific custom post type single page.
This is a small excerpt from my code. I'm using this to trigger the media library.
var uploader = wp.media({
title: 'Upload Image',
multiple: false
}).open()
.on('select', function(e){
// Some code here
});
Then I am filtering the library to show only certain attachments in the library, by using this filter here and by using the $_REQUEST to get the current post id:
function show_current_user_attachments( $query = array() ) {
//Modify the query here to show current user attachments only
return $query;
}
add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments', 10, 1 );
So far so good but I need another separate piece of logic on the current post. I need to trigger another wp.media that is entirely different from this one. It needs to not have the upload image functionality and it needs to show different attachments in the library.
Simply put, my question is how can I extend the wp.media and pass different arguments that I can process in the 'ajax_query_attachments_args' filter so I have 2 entirely different media popups with different functionality?
Thanks in advance!
Topic media-settings media-modal media-library media Wordpress
Category Web