From 579f04fb06a67d9842a9ec80ab7d1732843d3482 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 2 Feb 2018 07:47:03 +0000 Subject: [PATCH] Media: Avoid a PHP warning in `wp_calculate_image_srcset()` if a plugin returns a non-array value via `wp_calculate_image_srcset` filter. Props mrmadhat, codegrau. Fixes #43201. git-svn-id: https://develop.svn.wordpress.org/trunk@42639 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/media.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 1e6a4e5f58..7bfda66f1c 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -1205,7 +1205,7 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac $sources = apply_filters( 'wp_calculate_image_srcset', $sources, $size_array, $image_src, $image_meta, $attachment_id ); // Only return a 'srcset' value if there is more than one source. - if ( ! $src_matched || count( $sources ) < 2 ) { + if ( ! $src_matched || ! is_array( $sources ) || count( $sources ) < 2 ) { return false; }