From 5a3fb502cbde11b74123b11b7a905f10bebfbdf5 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 5 Feb 2014 02:06:10 +0000 Subject: [PATCH] TinyMCE: set the proper caption width when clicking image resize handle on image with caption. Props gcorne, fixes #27009, see #24067. git-svn-id: https://develop.svn.wordpress.org/trunk@27098 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js | 9 +++++++-- 1 file changed, 7 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 f3e66e6e4c..6681eda11c 100644 --- a/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js +++ b/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js @@ -495,11 +495,16 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { }); editor.on( 'ObjectResized', function( event ) { - var parent, + var parent, width, node = event.target; if ( node.nodeName === 'IMG' && ( parent = editor.dom.getParent( node, '.wp-caption' ) ) ) { - editor.dom.setStyle( parent, 'width', 10 + event.width + 'px' ); + width = event.width || editor.dom.getAttrib( node, 'width' ); + + if ( width ) { + width = parseInt( width, 10 ) + 10; + editor.dom.setStyle( parent, 'width', width + 'px' ); + } } });