title: wp.mce.views gallery override default 'editor-gallery' template
body: <p>Prior to 4.2 we could override the default MCE gallery template with this code:</p>
  
  <pre><code>var galleryview = wp.mce.views.get('gallery');
  galleryview.getContent = function(){
    this.template = media.template( 'editor-gallery-dtbaker-flexslider' );
    return this.template(this.shortcode.attrs.named);
  }
  </code></pre>
  
  <p>this no longer works. Is there a way to override the default 'gallery' view without re-registering it? This works (by copying and modifying the default code from mce-view.js) but I feel there should be a better way than re-registering the entire view. </p>
  
  <p>Is this possible after the mce view rewrite?  <a href="https://core.trac.wordpress.org/ticket/31412" rel="noreferrer">https://core.trac.wordpress.org/ticket/31412</a></p>
  
  <p>Here's code that works in 4.2:</p>
  
  <pre><code>add_action( 'admin_print_footer_scripts', 'my_admin_footer_scripts', 100 );
  function my_admin_footer_scripts(){ ?&gt;
  &lt;script type="text/javascript"&gt;
  ( function( $ ) {
  // start code copied from mce-view.js
  var postID = $( '#post_ID' ).val() || 0;
  var custom_gallery = _.extend( {}, {
  
      edit: function( text, update ) {
          var media = wp.media[ this.type ],
              frame = media.edit( text );
  
          this.pausePlayers &amp;&amp; this.pausePlayers();
  
          _.each( this.state, function( state ) {
              frame.state( state ).on( 'update', function( selection ) {
                  update( media.shortcode( selection ).string() );
              } );
          } );
  
          frame.on( 'close', function() {
              frame.detach();
          } );
  
          frame.open();
      },
      state: [ 'gallery-edit' ],
      template: wp.media.template( 'editor-gallery' ),
  
      initialize: function() {
          var attachments = wp.media.gallery.attachments( this.shortcode, postID ),
              attrs = this.shortcode.attrs.named,
              self = this;
  
          if(typeof attrs.slider != 'undefined'){
              switch(attrs.slider){
                  case 'flexslider':
                      this.template = wp.media.template( 'editor-gallery-dtbaker-flexslider' );
                      break;
                  case 'flex':
                      this.template = wp.media.template( 'editor-gallery-dtbaker-flex' );
                      break;
                  default:
                  // leave the existing template (editor-gallery)
              }
          }
          attachments.more()
              .done( function() {
                  attachments = attachments.toJSON();
                  _.each( attachments, function( attachment ) {
                      if ( attachment.sizes ) {
                          if ( attrs.size &amp;&amp; attachment.sizes[ attrs.size ] ) {
                              attachment.thumbnail = attachment.sizes[ attrs.size ];
                          } else if ( attachment.sizes.thumbnail ) {
                              attachment.thumbnail = attachment.sizes.thumbnail;
                          } else if ( attachment.sizes.full ) {
                              attachment.thumbnail = attachment.sizes.full;
                          }
                      }
                  } );
                  self.render( self.template( {
                      attachments: attachments,
                      columns: attrs.columns ? parseInt( attrs.columns, 10 ) : wp.media.galleryDefaults.columns
                  } ) );
              } )
              .fail( function( jqXHR, textStatus ) {
                  self.setError( textStatus );
              } );
      }
  } );
  wp.mce.views.unregister('gallery');
  wp.mce.views.register('gallery',custom_gallery);
  })(jQuery);
  &lt;?php }
  </code></pre>
  
  <p>I have tried this as well and no go:</p>
  
  <pre><code>            var dtbaker_gallery = wp.mce.views.get('gallery');
              dtbaker_gallery = dtbaker_gallery.extend({
                  template: wp.media.template( 'editor-gallery-dtbaker-flexslider' )
              });
  </code></pre>