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 ={
        title: 'Upload Image',
        multiple: false
    .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 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 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!

, , , 0v3rth3d4wn 2 years 2020-01-12T08:42:23-05:00 0 Answers 81 views 0

Leave an answer