Make WordPress Core


Ignore:
Timestamp:
10/27/2017 05:04:04 AM (7 years ago)
Author:
westonruter
Message:

Widgets: Prevent showing underlying attachment excerpt as caption when empty caption value is supplied in Image widget.

Allow underlying attachment to display if caption is null.

Props miyauchi, westonruter.
See #39993.
Fixes #42350.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-media-image.php

    r41696 r42030  
    178178        }
    179179        if ( $attachment ) {
    180             $caption = $attachment->post_excerpt;
    181             if ( $instance['caption'] ) {
     180            $caption = '';
     181            if ( ! isset( $instance['caption'] ) ) {
     182                $caption = $attachment->post_excerpt;
     183            } elseif ( trim( $instance['caption'] ) ) {
    182184                $caption = $instance['caption'];
    183185            }
Note: See TracChangeset for help on using the changeset viewer.