• Not sure if this is just something I did wrong with the code or if anyone else also had a similar issue with the uploader.

    In my custom meta box class i use the new uploader and everything works 100% in the posts, page and custom post type pages.

    However when I included the new uploader into my settings api class, each time I click the upload button 2 instances of the uploader is opened?

    I tried tracing the uploader events and tracing the button events but cannot see what i have done wrong here?

    Any help would be greatly appreciated.

    PS. :
    Server: IIS 7
    PHP Version: 5.4.0
    No plugins active or installed

    Code for upload button:

    case 'upload':
    	echo '<input class="' . $field_class . '" type="text" id="' . $id . '" name="tsrespo_options[' . $id . ']" value="' . esc_attr( $options[$id] ) . '" />';
    
        echo '<input id="' . $id . '_upload_button" class="button" type="button" value="Upload Image" />';
    
        echo '<script type="text/javascript">
    		    jQuery(document).ready(function($){
                    $("#' . $id . '_upload_button").click(function(e) {
                        var frame = wp.media({
                            title: "Choose Image",
                            multiple: false,
                            library: { type: "image" },
                            button: { text: "Ok" }
                        });
                        frame.on("select", function() {
                            var attachment = frame.state().get("selection").first().toJSON();
                            $("#' . $id . '").val(attachment.url);
                        });
                        frame.open();
                    });
                });
            </script>';
    
    	if ( $desc != '' )
    		echo '<br /><span class="description">' . $desc . '</span>';
    
    	break;
  • The topic ‘WP 3.5 Media Uploader’ is closed to new replies.