From 54a6a8e137274dc7fab33296f98f6fb6d76166ae Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 8 Apr 2015 17:11:27 +0000 Subject: [PATCH] Don't allow whitespace-only image captions from the Media modal. Captions containing only whitespace trick `image_add_caption()` into thinking a caption is required, but the empty caption text confuses wpeditimage into stripping the 'align' class specified by the user. Fixes #21848. Built from https://develop.svn.wordpress.org/trunk@32079 git-svn-id: http://core.svn.wordpress.org/trunk@32058 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 6 ++++++ wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 7a01af9657..2c287e1589 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -2445,7 +2445,13 @@ function wp_ajax_send_attachment_to_editor() { $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium'; $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; + + // No whitespace-only captions. $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : ''; + if ( '' === trim( $caption ) ) { + $caption = ''; + } + $title = ''; // We no longer insert title tags into tags, as they are redundant. $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt ); } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 3211ebecfe..e4a7ff94f2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-beta4-32078'; +$wp_version = '4.2-beta4-32079'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.