I have a meta box upload button and I want to upload multiple images using that button.

Firstly I enqueue required scripts:

add_action( 'admin_print_scripts-post-new.php', 'mycpt_admin_script', 11 );
add_action( 'admin_print_scripts-post.php', 'mycpt_admin_script', 11 );

function portfolio_admin_script() {
    global $post_type;
    if( 'mycpt' == $post_type )
    wp_enqueue_script( 'mycpt-script', get_stylesheet_directory_uri() . 'mycpt.js' );

mycpt.js looks like:

jQuery(document).ready(function() {
   jQuery('#cptbutton').click(function() {
       tb_show('', 'media-upload.php?type=image&TB_iframe=true');
       return false;

And then I just simply add meta box with this button:

<input id="cptbutton" type="button" value="Upload Image" />

Of course when I click it the Thickbox pops up with:

 Drop files here or

    [ Select Files ]

Plot twist - the files are already on the server (so I don't want to upload them all over again for every other post) and I want to just attach them to current post via Media Library tab:

Media Library

When I click on any of these above and click "Insert into Post" it just adds one image, and it's over.

How to select multiple images from Media Library? Is it even possible or my logic is wrong and I have to try something else?

In short words - I want to upload / attach images for post's sidebar (it's replacing Featured Images). I'd love to just drag & drop multiple images or select multiple images from Media Library although I have no idea how to do that? I don't want to use Gallery.

  • Can you not hold down ctrl (Windows/Linux) when you click the images in the media panel? – s_ha_dum Dec 8 '13 at 15:55
  • The only clickable element is "Show" (even while holding ctrl, it does not seem to help unforunately), even if I somehow manage to select multiple images from the list above, how do I insert them all (as an array)? – Wordpressor Dec 8 '13 at 16:05
  • What version of WP is this? – s_ha_dum Dec 8 '13 at 16:07
  • 3.7.1. I'm not sure if my post is clear enough - I just want to select multiple images from Media Library and then click Insert into post (after that I will store them as array in meta box value). I've beeen Googling for a while and not sure if it's even possible... I hope I'm wrong though, because it looks like the perfect, very intuitive way of adding multiple additional images to a post. – Wordpressor Dec 8 '13 at 16:10
  • Exactly how do you get to that screen? I have seen it but can't manage to find it just now? o_0 – s_ha_dum Dec 8 '13 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.