From cb877e10ba3d3ec0d5bf97308960768e5012af53 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 27 Oct 2017 05:05:51 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@42030 git-svn-id: http://core.svn.wordpress.org/trunk@41864 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/widgets/class-wp-widget-media-image.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index e5900953f2..5023a9c225 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-beta4-42029'; +$wp_version = '4.9-beta4-42030'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/widgets/class-wp-widget-media-image.php b/wp-includes/widgets/class-wp-widget-media-image.php index 780ceacad5..4ebc42d66e 100644 --- a/wp-includes/widgets/class-wp-widget-media-image.php +++ b/wp-includes/widgets/class-wp-widget-media-image.php @@ -177,8 +177,10 @@ class WP_Widget_Media_Image extends WP_Widget_Media { $attachment = get_post( $instance['attachment_id'] ); } if ( $attachment ) { - $caption = $attachment->post_excerpt; - if ( $instance['caption'] ) { + $caption = ''; + if ( ! isset( $instance['caption'] ) ) { + $caption = $attachment->post_excerpt; + } elseif ( trim( $instance['caption'] ) ) { $caption = $instance['caption']; }