From eaae2546f5b9c83ef86443bd9a542d1fe695048b Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 1 Dec 2015 20:50:25 +0000 Subject: [PATCH] Media: don't use `get_media_embedded_in_content()` in `wp_make_content_images_responsive()`. Adds unit test. Props azaozz. Fixes #34807. Built from https://develop.svn.wordpress.org/trunk@35753 git-svn-id: http://core.svn.wordpress.org/trunk@35717 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 11 ++++++----- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index c4aac252e4..06c27cbc7f 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1206,11 +1206,13 @@ function wp_calculate_image_sizes( $size, $image_src = null, $image_meta = null, * @return string Converted content with 'srcset' and 'sizes' attributes added to images. */ function wp_make_content_images_responsive( $content ) { - $images = get_media_embedded_in_content( $content, 'img' ); + if ( ! preg_match_all( '/]+>/', $content, $matches ) ) { + return $content; + } $selected_images = $attachment_ids = array(); - foreach( $images as $image ) { + foreach( $matches[0] as $image ) { if ( false === strpos( $image, ' srcset=' ) && preg_match( '/wp-image-([0-9]+)/i', $image, $class_id ) && ( $attachment_id = absint( $class_id[1] ) ) ) { @@ -3506,12 +3508,11 @@ function get_media_embedded_in_content( $content, $types = null ) { * Filter the embedded media types that are allowed to be returned from the content blob. * * @since 4.2.0 - * @since 4.4.0 Added 'img' to the allowed types. * * @param array $allowed_media_types An array of allowed media types. Default media types are - * 'audio', 'video', 'object', 'embed', 'iframe', and 'img'. + * 'audio', 'video', 'object', 'embed', and 'iframe'. */ - $allowed_media_types = apply_filters( 'media_embedded_in_content_allowed_types', array( 'audio', 'video', 'object', 'embed', 'iframe', 'img' ) ); + $allowed_media_types = apply_filters( 'media_embedded_in_content_allowed_types', array( 'audio', 'video', 'object', 'embed', 'iframe' ) ); if ( ! empty( $types ) ) { if ( ! is_array( $types ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 9f8744b7d7..10df911338 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-RC1-35752'; +$wp_version = '4.4-RC1-35753'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.