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 );