I have this code.
$('.custom-browse-button').on('click', function(e) {
e.preventDefault();
var wpMedia = wp.media.frames.file_frame = wp.media({
'library': {
type: 'image'
},
'multiple': true
});
wpMedia.open()
.on('select', function(e) {
var uploaded_image = wpMedia.state().get('selection').toJSON();
// already done with select.
console.log(uploaded_image);
});
});
In ajax request there are these parameters in the method POST:
action:query-attachments
post_id:0
query[post_mime_type]:image
query[orderby]:date
query[order]:DESC
query[posts_per_page]:40
query[paged]:1
I want to add something more fore checking and hooks. Example: my_filtered_user_id=3
OR media_width_eqm=1000
How to add these things in wp.media?
Update:
Now I am able to send parameter to upload hooks using this answer.
However I still unable to send GET or POST data to browse media hooks (ajax_query_attachments_args
) using that answer.
$('.custom-browse-button').on('click', function(e) {
e.preventDefault();
var wpMedia = wp.media.frames.file_frame = wp.media({
'library': {
type: 'image'
},
'multiple': true
});
wpMedia.uploader.options.uploader.params.my_filtered_user_id = 3;
wpMedia.open()
.on('select', function(e) {
var uploaded_image = wpMedia.state().get('selection').toJSON();
// already done with select.
console.log(uploaded_image);
});
});