Elliot here from the “Advanced Custom Fields” plugin.
I’m working on integrating the new WP 3.5 uploader into the ACF plugin and can’t find much documentation about the new uploader at all!
Creating an uploader frame is easy, that can be done like this:
// Create the media frame.
acf.media = wp.media({
title : 'title',
button : {
text: 'button',
},
multiple: true
});
However, what if you want to change multiple to false and for another field?
Basically, I would like to create only 1 wp.media object, but then update the options when needed (when you click “upload image”, etc) and force a render refresh on the uploader.
I’ve played around with stuff like this:
acf.media.title.get().refresh()
But that doesn’t work…
Any help will be greatly apreciated
Cheers
Elliot
Solved!
Not sure if this is the correct method, but after hours of console logging I discovered that this code:
will update the multiple option and therefore change how many images can be selected in the new uploader.
If someone finds a nicer way, I’d love to hear it
Looks like you’ve figured it out but seeing I use ACF all the time I figured I could link you to a couple of awesome posts about the media uploader in 3.5 as the codex still aren’t updated yet.
Check out: Using the WordPress 3.5 Media Uploader within plugins
and Building a Better Image Widget with the New WordPress Media Manager
Keep up the great work with ACF 🙂