I am trying to use WordPress' Media Library in my plugin, making it upload to plugin's images folder. It will be used on my plugin's backend page.

I am using `wp_enqueue_media()` in `admin_enqueue_scripts` action, and later creating the media frame in Javascript using `wp.media`.

So far I've been making workarounds using `upload_dir` filter. I've managed to make it upload to the proper folder using
 
	add_filter( 'plupload_default_params', array( $this, 'plupload_default_params_filter' ) );

    function plupload_default_params_filter($params) {
        //check if it's the plugin form 
		if(isset($_GET['type']) && isset($_GET['action']) && 'edit' == $_GET['action']){
		    $params['subfolder'] = $_GET['type'];
		}
		return $params;
	}

which causes the ajax `$_POST` array to contain `subfolder` key so I can check it in `upload_dir` filter:

	function change_upload_dir( $args ) {
		if(isset($_POST['subfolder']) {
			//change upload dir accordingly
        }
    }
}

This works fine for uploading through drag-and-drop, but when the attachments are loaded in the library (through AJAX `query-attachments` action), I have no way of knowing if it's called from the plugin media library, so it defaults to `uploads/year/month`. 

Is there any way to change it for a certain Media Library object? I don't want to change the upload_dir globally, as I want blog posts' attachments to go to default location.