wp.media events list
-
Hi,
I’m developing a gallery and this is the JS code for the media library:jQuery(document).ready(function(){ var custom_uploader; jQuery('#upload_image_button').click(function(e) { //forbid default behaviour of the event e.preventDefault(); //If the uploader object has already been created, reopen the dialog if (custom_uploader) { custom_uploader.open(); return; } //Extend the wp.media object to create the window custom_uploader = wp.media.frames.file_frame = wp.media({ title: 'Choose Image', button: { text: 'Choose Image' }, multiple: false }); //When a file is selected, grab the URL and set it as the text field's value custom_uploader.on('select', function() { // Get media attachment details from the frame state attachment = custom_uploader.state().get('selection').first().toJSON(); jQuery('#upload_image').val(attachment.url); }); //Open the uploader dialog custom_uploader.open(); }); });
Now I need to get the image ID to arrange images from the media library which will take part on the gallery using PHP so I thought an AJAX/JSON call should be good to pass data from the media window created with wp.media after the user clicks on “Choose image”.
How can I get this event?
I cant’ find a list of events associated to wp.media but in the code above there’s:custom_uploader.on('select', function() {...}
so I think there could be a sort of custom_uploader.on(‘buttonclick’ function(){…}, isn’t it?
Otherwise how can I accomplish it?
Thank you!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wp.media events list’ is closed to new replies.