From effedfdff458112902f2e3932f6b7865ecb87782 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 16 Mar 2016 02:18:25 +0000 Subject: [PATCH] Responsive images: do not attempt to create srcset when the image meta is missing or corrupted. Props overclokk, jaspermdegroot, joemcgill. Fixes #35480. Built from https://develop.svn.wordpress.org/trunk@37002 git-svn-id: http://core.svn.wordpress.org/trunk@36969 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 7 ++++++- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 6b0187a932..7b99f95980 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -985,7 +985,7 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac */ $image_meta = apply_filters( 'wp_calculate_image_srcset_meta', $image_meta, $size_array, $image_src, $attachment_id ); - if ( empty( $image_meta['sizes'] ) ) { + if ( empty( $image_meta['sizes'] ) || strlen( $image_meta['file'] ) < 4 ) { return false; } @@ -1060,6 +1060,11 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac */ foreach ( $image_sizes as $image ) { + // Check if image meta isn't corrupted. + if ( ! is_array( $image ) ) { + continue; + } + // If the file name is part of the `src`, we've confirmed a match. if ( ! $src_matched && false !== strpos( $image_src, $dirname . $image['file'] ) ) { $src_matched = true; diff --git a/wp-includes/version.php b/wp-includes/version.php index 073d2b39ff..037c1d46a4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-beta3-37001'; +$wp_version = '4.5-beta3-37002'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.