2

What is the event listener for selecting an image in the media.editor javascript. I am attempting to add a multiple image selector to a custom plugin, and I need to show the user what images they have selected, before actually hitting the 'Select' button or the 'Insert' button. I have the media.editor configured like this:

file_frame = wp.media.frames.file_frame = wp.media({
    title: $(this).data('uploader_title'),
    button: {
        text: $(this).data('uploader_button_text')
    },
    multiple: true,
    library:{type:'image'}
});

Setting multiple to true doesn't seem to do anything different than setting it to false. In other words before the user goes to insert the images, what is the event callback that will listen to whether or not an image is checked for selection? The 'select' event is not it. Is there an API for the media.editor script?

0

Found out that overriding some of the wp.media.editor objects methods is the best solution, because it allows you to customize the event handling, but will also preserve a lot of the backend processing and handling that WP has in place for processing images. I basically overrode wp.media.editor.send.attachment, wp.media.gallery.shortcode with my own methods, and wp.media.editor.remove, in order to send the data these methods produce to PHP via an ajax call and process them as I see fit. Thanks to this guy's guidance. Awesome! https://japaalekhin.llemos.com/how-to-use-wp3-5-media-manager-in-your-plugin-or-theme

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.