Support » Alpha/Beta/RC » Help Implementing new Media Uploader

  • Resolved dicegame


    Hi Guys,

    I currently am using the only Media Uploader with functions such as tb_show & window.send_to_editor = function(html) { } to obtain the html of the selected attachment so i can perform tasks with it. One of these tasks was to obtain the title of the attachment from the returned html. This however does not work in the 3.5 Beta 3.

    I am interested in getting the new media uploader to work on a custom meta box image uploader. Could someone point me in the correct direction? I have tried copying the featured image JS for the uploader however it is failing to work.

    Do you guys have any idea on how I could get it to work or possible refer me to some documentation for the new system?

    I am also looking to support both versions. So e.g. if WP version < 3.5 run the old media uploader else run new media uploader.

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • wWave


    Hi dicegame,

    I’ve been trying to do the same, I’ve been trying to do the same and managed to do it on custom meta boxes as long as the already is a wp_editor in place.

    The HTML
    <input type="text" id="my_key" name="my_key" value=""><input id="file_button" data-update="Select File" data-choose="Choose a File" type="button" value="Select" class="button">

    I’m calling the new Media Uploader using javascript:

    			var targetfield="my_key";
    			jQuery("#file_button").click( function( event ) {
    			var jQueryel = jQuery(this);
    			// If the media frame already exists, reopen it.
    			if ( typeof(custom_file_frame)!=="undefined" ) {;
    			// Create the media frame.
    			custom_file_frame = ={
    				// Set the title of the modal.
    				// Tell the modal to show only images. Ignore if want ALL
    				library: {
    					type: 'image'
    				// Customize the submit button.
    				button: {
    					// Set the text of the button.
    			custom_file_frame.on( "select", function() {
    			// Grab the selected attachment.
    			var attachment = custom_file_frame.state().get("selection").first();
    			// Update value of the targetfield input with the attachment url.

    Hope this helps, I’m still trying to make it work when there is not a wp_editor in the page, but I’m getting errors of undefined elements.

    Any help to improve it will be hugely appreciated!!

    Hi, the problem is that
    custom_file_frame.on( "select", function()...
    dont creates dynamic HTML like live() or jQuery(document).on('on', '.selector', function() {});
    I’ve tried jQuery(document).on('on', custom_file_frame, function() {}); but dont works…
    any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help Implementing new Media Uploader’ is closed to new replies.