From 77133d2c9626a81d1f8ec69d7bb8c78c8b0690db Mon Sep 17 00:00:00 2001 From: azaozz Date: Fri, 24 Feb 2012 19:18:59 +0000 Subject: [PATCH] Don't show edit/remove image buttons in the visual editor when an image is floated, doesn't have a caption and there is text in the same paragraph, props solarissmoke, fixes #19611 git-svn-id: http://svn.automattic.com/wordpress/trunk@19984 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../plugins/wpeditimage/editor_plugin_src.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js index 3d2705851a..756154cf38 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js @@ -69,17 +69,24 @@ // show editimage buttons ed.onMouseDown.add(function(ed, e) { + var target = e.target; - if ( e.target && ( e.target.nodeName == 'IMG' || (e.target.firstChild && e.target.firstChild.nodeName == 'IMG') ) ) { + if ( target.nodeName != 'IMG' ) { + if ( target.firstChild && target.firstChild.nodeName == 'IMG' && target.childNodes.length == 1 ) + target = target.firstChild; + else + return; + } + + if ( ed.dom.getAttrib(target, 'class').indexOf('mceItem') == -1 ) { mouse = { x: e.clientX, y: e.clientY, - img_w: e.target.clientWidth, - img_h: e.target.clientHeight + img_w: target.clientWidth, + img_h: target.clientHeight }; - if ( ed.dom.getAttrib(e.target, 'class').indexOf('mceItem') == -1 ) - ed.plugins.wordpress._showButtons(e.target, 'wp_editbtns'); + ed.plugins.wordpress._showButtons(target, 'wp_editbtns'); } });