diff --git a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js index 6725535a34..d9e0af9833 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -82,7 +82,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { return ''; } - out = b.replace( /
]+)>\s*
]+>([\s\S]+?)<\/dt>\s*
]+>([\s\S]*?)<\/dd>\s*<\/dl>/gi, function( a, b, c, caption ) { + out = b.replace( /\s*
]+)>\s*
]+>([\s\S]+?)<\/dt>\s*
]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) { var id, classes, align, width; width = c.match( /width="([0-9]*)"/ ); @@ -116,7 +116,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]'; }); - if ( out.indexOf('[caption') !== 0 ) { + if ( out.indexOf('[caption') === -1 ) { // the caption html seems broken, try to find the image that may be wrapped in a link // and may be followed by

with the caption text. out = b.replace( /[\s\S]*?((?:]+>)?]+>(?:<\/a>)?)(

[\s\S]*<\/p>)?[\s\S]*/gi, '

$1

$2' );