diff --git a/client/components/tinymce/plugins/media/plugin.jsx b/client/components/tinymce/plugins/media/plugin.jsx index 7f52b7774c1b78..c7aa554a983f47 100644 --- a/client/components/tinymce/plugins/media/plugin.jsx +++ b/client/components/tinymce/plugins/media/plugin.jsx @@ -281,28 +281,28 @@ function mediaButton( editor ) { renderDropZone( { visible: event.type === 'dragend' } ); } + editor.addCommand( 'wpcom_add_media', () => { + var selectedSite = sites.getSelectedSite(); + if ( selectedSite ) { + MediaActions.clearValidationErrors( selectedSite.ID ); + } + + renderModal( { + visible: true, + initialActiveView: MediaModalViews.LIST + } ); + } ); + editor.addButton( 'wpcom_add_media', { classes: 'btn wpcom-icon-button media', - + cmd: 'wpcom_add_media', title: i18n.translate( 'Add Media' ), - onPostRender: function() { this.innerHtml( ReactDomServer.renderToStaticMarkup( ) ); - }, - onclick: function() { - var selectedSite = sites.getSelectedSite(); - if ( selectedSite ) { - MediaActions.clearValidationErrors( selectedSite.ID ); - } - - renderModal( { - visible: true, - initialActiveView: MediaModalViews.LIST - } ); } } );