Make WordPress Core


Ignore:
Timestamp:
12/01/2015 08:49:13 PM (11 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/tests/phpunit/tests/media.php

    r35751 r35753  
    10201020                $img_no_size_id = str_replace( 'wp-image-', 'id-', $img );
    10211021                $img_with_sizes_attr = str_replace( '<img ', '<img sizes="99vw" ', $img );
     1022                $img_xhtml = str_replace( ' />', '/>', $img );
     1023                $img_html5 = str_replace( ' />', '>', $img );
    10221024
    10231025                // Manually add srcset and sizes to the markup from get_image_tag();
    … …  
    10261028                $respimg_no_width_height = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_no_width_height );
    10271029                $respimg_with_sizes_attr = preg_replace('|<img ([^>]+) />|', '<img $1 ' . $srcset . ' />', $img_with_sizes_attr );
     1030                $respimg_xhtml = preg_replace( '|<img ([^>]+)/>|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_xhtml );
     1031                $respimg_html5 = preg_replace( '|<img ([^>]+)>|', '<img $1 ' . $srcset . ' ' . $sizes . ' />', $img_html5 );
    10281032
    10291033                $content = '
    … …  
    10411045
    10421046                        <p>Image, with sizes attribute. Should NOT have two sizes attributes.</p>
    1043                         %5$s';
    1044 
    1045                 $content_unfiltered = sprintf( $content, $img, $img_no_size_in_class, $img_no_width_height, $img_no_size_id, $img_with_sizes_attr );
    1046                 $content_filtered = sprintf( $content, $respimg, $respimg_no_size_in_class, $respimg_no_width_height, $img_no_size_id, $respimg_with_sizes_attr );
     1047                        %5$s
     1048
     1049                        <p>Image, XHTML 1.0 style (no space before the closing slash). Should have srcset and sizes.</p>
     1050                        %6$s
     1051
     1052                        <p>Image, HTML 5.0 style. Should have srcset and sizes.</p>
     1053                        %7$s';
     1054
     1055                $content_unfiltered = sprintf( $content, $img, $img_no_size_in_class, $img_no_width_height, $img_no_size_id, $img_with_sizes_attr, $img_xhtml, $img_html5 );
     1056                $content_filtered = sprintf( $content, $respimg, $respimg_no_size_in_class, $respimg_no_width_height, $img_no_size_id, $respimg_with_sizes_attr, $respimg_xhtml, $respimg_html5 );
    10471057
    10481058                $this->assertSame( $content_filtered, wp_make_content_images_responsive( $content_unfiltered ) );
Note: See TracChangeset for help on using the changeset viewer.