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
This commit is contained in:
Andrew Ozz 2016-08-23 04:42:58 +00:00
parent 8d48e9a685
commit d96cb127ee
1 changed files with 9 additions and 2 deletions

View File

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