621 posts Don't be so humble - you are not that great.
  • Affiliate Level 3
  • Author Level 7
  • Collector Level 2
  • Copyright Ninja
+7 more
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 :)

2280 posts
  • Top Monthly Author
  • Weekly Top Seller
  • Community Superstar
  • Industrious API Inventor
+15 more
revaxarts
says
621 posts Don't be so humble - you are not that great.
  • Affiliate Level 3
  • Author Level 7
  • Collector Level 2
  • Copyright Ninja
+7 more
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
  • 3 Years of Membership
  • Collector Level 1
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
  • 5 Years of Membership
  • Collector Level 1
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
    });
});

});
621 posts Don't be so humble - you are not that great.
  • Affiliate Level 3
  • Author Level 7
  • Collector Level 2
  • Copyright Ninja
+7 more
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
  • 4 Years of Membership
  • Affiliate Level 2
  • Collector Level 4
  • Exclusive Author
+1 more
deckerweb
says
See this Sample Plugin by Thomas Griffin which demonstrates the new stuff: https://github.com/thomasgriffin/New-Media-Image-Uploader
2 posts
  • Collector Level 1
  • Exclusive Author
  • 4 Years of Membership
  • Ukraine
slamik
says

I don’t know why, but “Upload file” don’t whant to work on frontend. Everithing else is ok, I can choose media from library but not to upload :( Who faced with such issue?

2 posts
  • Collector Level 1
  • Exclusive Author
  • 4 Years of Membership
  • Ukraine
slamik
says

I don’t know why, but “Upload file” don’t whant to work on frontend. Everithing else is ok, I can choose media from library but not to upload :( Who faced with such issue?

I’ve found that jquery select pack cause this issue.

by
by
by
by
by
by