535 posts
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
plusquare says

Houdy mates,

Anyone knows where I can find the new wordpress 3.5 media uploader api? Or something similar I’ve tried to search in the codex but nothing solid comes up :S

Specifically the javascript wp.media.editor functions and handling.

Thanks for any help :)

2001 posts
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 4-5 years
  • Austria
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Microlancer Beta Tester
+3 more
revaxarts says
535 posts
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
plusquare says

The thing is I want something more personalized, I already made this:

//Prepare frame
                    var frame = wp.media({
                        title : 'Pick the images for this work',
                        multiple : true,
                        library : { type : 'image'},
                        button : { text : 'Insert' },
                    });
                    frame.on('close',function() {
                        // get selections and save to hidden input plus other AJAX stuff etc.
                        var selection = frame.state().get('selection');
                        console.log(selection["_byId"]);
                    });
                    frame.on('open',function() {
                        var selection = frame.state().get('selection');

                        //Get ids array from
                        ids = jQuery('#<?php echo $this->id; ?>').val().split(',');
                        ids.forEach(function(id) {
                            attachment = wp.media.attachment(id);
                            attachment.fetch();
                            selection.add( attachment ? [ attachment ] : [] );
                        });
                    });
                    frame.open();

But I wanted to see what I can do with it, was trying to find wp’s actual documentation on this

1 post
  • Bought between 1 and 9 items
  • Has been a member for 2-3 years
onyxns says

Thank you plusquare! I like this approach much better than overriding wp.media.editor.send.attachment function. Any idea on how to enable “Attachment Display Settings” in the sidebar? right now only “Attachment Details” is being displayed.

1 post
  • Bought between 1 and 9 items
  • Has been a member for 4-5 years
heydays says
Looking for some documentation on this myself. Found an approach for easily fetching attachment-data though:
$('#somelink').on('click', function(event){

event.preventDefault();

var frame = wp.media({
    title: "Select Image",
    multiple: false,
    library: { type: 'image' },
    button : { text : 'add image' }
});
frame.on( 'select', function() {
    var selection = frame.state().get('selection');
    selection.each(function(attachment) {
        console.log(attachment);
        // this will return an object with all the attachment-details
    });
});

});
535 posts
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Portugal
plusquare says

In my case I ended up in using admin-ajax get attachment function to display the actual images on the admin as the attachment fetch only functioned after I opened media picker the first time. Got it working exactly as I wanted :)

16 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Germany
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
deckerweb says
See this Sample Plugin by Thomas Griffin which demonstrates the new stuff: https://github.com/thomasgriffin/New-Media-Image-Uploader
by
by
by
by
by
by