WordPress.org

Make WordPress Core

Changeset 32079


Ignore:
Timestamp:
04/08/2015 05:10:53 PM (4 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r32055 r32079  
    24462446        $size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
    24472447        $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
     2448
     2449        // No whitespace-only captions.
    24482450        $caption = isset( $attachment['post_excerpt'] ) ? $attachment['post_excerpt'] : '';
     2451        if ( '' === trim( $caption ) ) {
     2452            $caption = '';
     2453        }
     2454
    24492455        $title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
    24502456        $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt );
Note: See TracChangeset for help on using the changeset viewer.