From d96cb127ee27ef9288b5506c2fbb857f771c67f2 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 23 Aug 2016 04:42:58 +0000 Subject: [PATCH] TinyMCE: make sure the temporary id is removed when using the default image dialog and inserting an external image. Props fomenkoandrey for reporting and testing. Fixes #37467. git-svn-id: https://develop.svn.wordpress.org/trunk@38328 602fd350-edb4-49c9-b593-d223f7449a82 --- .../js/tinymce/plugins/wpeditimage/plugin.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index 890da1c2c8..4fe072137a 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -630,7 +630,8 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { captionId = '', captionAlign = '', captionWidth = '', - wrap, parent, node, html, imgId; + imgId = null, + wrap, parent, node, html; // Temp image id so we can find the node later data.id = '__wp-temp-img-id'; @@ -796,7 +797,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } imgNode = dom.get('__wp-temp-img-id'); - dom.setAttrib( imgNode, 'id', imgId ); + dom.setAttrib( imgNode, 'id', imgId || null ); event.imgData.node = imgNode; }); @@ -976,6 +977,12 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { return getShortcode( content ); }; + editor.on( 'beforeGetContent', function( event ) { + if ( event.format !== 'raw' ) { + editor.$( 'img[id="__wp-temp-img-id"]' ).attr( 'id', null ); + } + }); + editor.on( 'BeforeSetContent', function( event ) { if ( event.format !== 'raw' ) { event.content = editor.wpSetImgCaption( event.content );