Make WordPress Core


Ignore:
Timestamp:
12/01/2015 08:49:13 PM (8 years ago)
Author:
wonderboymusic
Message:

Media: don't use get_media_embedded_in_content() in wp_make_content_images_responsive().

Adds unit test.

Props azaozz.
Fixes #34807.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r35725 r35753  
    12071207 */
    12081208function wp_make_content_images_responsive( $content ) {
    1209     $images = get_media_embedded_in_content( $content, 'img' );
     1209    if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
     1210        return $content;
     1211    }
    12101212
    12111213    $selected_images = $attachment_ids = array();
    12121214
    1213     foreach( $images as $image ) {
     1215    foreach( $matches[0] as $image ) {
    12141216        if ( false === strpos( $image, ' srcset=' ) && preg_match( '/wp-image-([0-9]+)/i', $image, $class_id ) &&
    12151217            ( $attachment_id = absint( $class_id[1] ) ) ) {
     
    35073509     *
    35083510     * @since 4.2.0
    3509      * @since 4.4.0 Added 'img' to the allowed types.
    35103511     *
    35113512     * @param array $allowed_media_types An array of allowed media types. Default media types are
    3512      *                                   'audio', 'video', 'object', 'embed', 'iframe', and 'img'.
    3513      */
    3514     $allowed_media_types = apply_filters( 'media_embedded_in_content_allowed_types', array( 'audio', 'video', 'object', 'embed', 'iframe', 'img' ) );
     3513     *                                   'audio', 'video', 'object', 'embed', and 'iframe'.
     3514     */
     3515    $allowed_media_types = apply_filters( 'media_embedded_in_content_allowed_types', array( 'audio', 'video', 'object', 'embed', 'iframe' ) );
    35153516
    35163517    if ( ! empty( $types ) ) {
Note: See TracChangeset for help on using the changeset viewer.