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. git-svn-id: https://develop.svn.wordpress.org/trunk@32079 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1ad5acb6a1
commit
7d18785497
|
@ -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 <img> 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 ) ) {
|
||||
|
|
Loading…
Reference in New Issue