title: Pre-Select Images when opening WordPress 3.5 media manager
body: <p>I've been playing around with the new media manager in WordPress and had some fun with it, but have reached the point where I'm banging my head against a wall.</p>
  
  <p>I have a custom meta box that I'd like to store some images in (well it's a hidden input and I'm currently storing their ID's, but could equally be the image objects), then making an AJAX call to show some thumbnails, which I have subsequently made draggable so users can reorder (not necessarily relevant just some background).</p>
  
  <p>My problem is that when I open the media manager, no images are selected, so if a user wants to edit the pictures in their gallery they need to select them all again.</p>
  
  <p>What I'm trying to figure out, is how do I open the media manager with the current images passed through so they are pre-selected.</p>
  
  <p>So, broadly, my code looks like this</p>
  
  <pre><code>jQuery('#myButton').click(function(e) {
    e.preventDefault();
    frame = wp.media({
      title : 'My Gallery Title',
      multiple : true,
      library : { type : 'image'},
      button : { text : 'Insert' },
    });
    frame.on('close',function() {
      // get selections and save to hidden input plus other AJAX stuff etc.
    }
    frame.open();
  });
  </code></pre>
  
  <p>My thought is that there must be either a parameter to pass into the frame (probably a JSON object of the images, or I need to create an event for </p>
  
  <pre><code>frame.on('open', function() {
    // Set selected images
  }
  </code></pre>
  
  <p>But I have tried both ways round and am not getting anywhere.</p>
  
  <p>It would appear possible, as changing the 'Featured Image' takes you to the library with the current one selected - I've just been unable to understand the core code sufficiently yet and hope someone else has !</p>