Support » Plugins » Hacks » Multiple media upload frames

  • Hello WordPress users,

    I’m stuck with a problem while building my WordPress plugin.

    I want to use 2 Media Upload iframes in on one plugin page.
    I tried multiple scripts. Curretly I’m using the code from a tutorial. But I also used this code.

    var file_frame;
        jQuery('.upload_button').live('click', function( event ){
            var clicked = $(this);
            if ( file_frame ) {
            file_frame = ={
                title: jQuery( this ).data( 'upload_image' ),
                button: {
                    text: jQuery( this ).data( 'uploader_button_text' )
                multiple: false
            file_frame.on( 'select', function() {
                attachment = file_frame.state().get('selection').first().toJSON();

    But this ain’t work for me.
    Im using 2 fields:

    <p><input type="text" name="upload_image" class="upload_image" />
           <input type="file" name="image" class="upload_button" /></p>


    <p><input type="text" name="edit_upload_image" class="upload_image" value="<?php echo $edit[0]->image ?>" />
            <input type="file" name="edit_image" class="upload_button" /></p>

    With the first field all the code works fine.
    But at the second field the code is not sending the url to my input field.

    The iframe works fine.
    I can select and upload al the images I want, but when I press ‘Select Image’ the url is not sended to the input area.

    Someone recognized this problem?
    Thanks 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Im still stuck on this problem..
    Someone who can help me out?

    Hey ronnyrook,
    I had the same problem, it’s easily fixed by removing these lines:

    if ( file_frame ) {;

    The problem with this is that each time the window is opened it will create a new instance of it (I don’t think there is a method of removing them), so this could pose performance problems if you have a ton of them on the same page. In my case there’s only two spots and it’s unlikely the ‘Choose’ buttons will be clicked a bunch of times, so this works!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple media upload frames’ is closed to new replies.