Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm wondering how to make WP3.5 media uploader return 2 or more items in attachement? It always runs once even if 2 items are selected. The code:

$('.button').on('click', function(){
     var send_attachment_backup = wp.media.editor.send.attachment;
          wp.media.editor.send.attachment = function(props, attachment){                                
               myFunction(attachment.url);
          wp.media.editor.send.attachment = send_attachment_backup;
     }
     wp.media.editor.open();
});

EDIT: My mistake. I'm doing wp.media.editor.send.attachment = send_attachment_backup; and it runs once. So the new questions would be: how to restore the original function after the latest item in the loop?

share|improve this question
add comment

1 Answer

I'd sugest you to properly handle new media modal integration. There's no need to hijack wp.media.editor object's attributes in order to use media modal in your plugins. You can inspire yourself from a demo integration plugin at github

Demo #4 best suits your needs I guess

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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