title: Insert wp gallery shortcode into custom field textarea
body: <p>Is there a way to insert wp gallery shortcode into custom metabox textarea ?
  I would like to have something like this:</p>
  
  <p>New metabox in post/page with textarea and below textarea there are a button to open wp browse media gallery lightbox. then when we have done to select few images as gallery, click the "insert gallery" button will insert the shortcode to the textarea custom field.</p>
  
  <p>I was able to show media library, now I don't have idea how to insert shortcode to the custom textarea when click button "insert gallery"</p>
  
  <p>Here my code so far:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;div class="uploader"&gt;
   &lt;textarea name="settings[_cs_shortcode_gallery]" id="_cs_shortcode_gallery"&gt;&lt;/textarea&gt;
   &lt;input class="button tf-browse-btn" name="_cs_shortcode_gallery_button" id="_cs_shortcode_gallery_button" value="Browse Gallery"/&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>var _custom_media = true,
        _orig_send_attachment = wp.media.editor.send.attachment;
    $('.tf-browse-btn').live('click', function(e) {
      var send_attachment_bkp = wp.media.editor.send.attachment;
      var button = $(this);
      var id = button.attr('id').replace('_button', '');
      _custom_media = true;
      wp.media.editor.send.attachment = function(props, attachment){
        if ( _custom_media ) {
          $("#"+id).val(attachment.url);
        } else {
          return _orig_send_attachment.apply( this, [props, attachment] );
        };
      }
      wp.media.editor.open(button);
      return false;
    });
    $('.add_media').on('click', function(){
      _custom_media = false;
    });
  </code></pre>
  
  <p>What I want to achieve now are:</p>
  
  <ul>
  <li>How to set Create Gallery Tab as default tab when open the modal</li>
  <li>Insert gallery shortcode to the custom textarea</li>
  </ul>
  
  <p>Please see the screenshot below for details</p>
  
  <p><a href="http://i.stack.imgur.com/m1l2e.png" rel="nofollow">http://i.stack.imgur.com/m1l2e.png</a></p>
  
  <p><a href="http://i.stack.imgur.com/y9Fi5.png" rel="nofollow">http://i.stack.imgur.com/y9Fi5.png</a></p>