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.
Merges [42639] to the 4.9 branch.
Fixes #43201.
Built from https://develop.svn.wordpress.org/branches/4.9@42669


git-svn-id: http://core.svn.wordpress.org/branches/4.9@42497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-02-07 23:49:41 +00:00
parent 1f26b2945d
commit 8461e3a896
2 changed files with 2 additions and 2 deletions

View File

@ -1203,7 +1203,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 ); $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. // 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; return false;
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.9.5-alpha-42668'; $wp_version = '4.9.5-alpha-42669';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.