In the past Media Library window could be called like this:
tb_show("Upload image", "media-upload.php?type=image&TB_iframe=1&width=640&height=520");
This still works in WP3.5. But I’m wondering how to open a new media manager? It’s no longer handled by Thickbox – tb_show()
.
Thanks for any advices!
From the article How to use WordPress 3.5 Media Uploader in Theme Options (by codestag.com), as seen in Using the WordPress 3.5 Media Uploader within plugins (by mikejolley.com). Mike Jolley’s article has quite some nice tricks.
Important note: if the page where the uploader is going to be used doesn’t already have all media JS APIs, then
wp_enqueue_media()
has to be called.So, supposing we have a button like this in a custom Meta Box:
The following script will call the new uploader and fill up the input text field
#_wpse_82857
with the attachment path when Insert into post is clicked.