Changeset 53480 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 06/09/2022 05:29:57 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r53465 r53480 1475 1475 $image = image_downsize( self::$large_id, 'thumbnail' ); 1476 1476 $expected = sprintf( 1477 '<img width="%1$d" height="%2$d" src="%3$s" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" />',1477 '<img width="%1$d" height="%2$d" src="%3$s" class="attachment-thumbnail size-thumbnail" alt="" decoding="async" loading="lazy" />', 1478 1478 $image[1], 1479 1479 $image[2], … … 1513 1513 $image = image_downsize( self::$large_id, 'thumbnail' ); 1514 1514 $expected = sprintf( 1515 '<img width="%1$d" height="%2$d" src="%3$s" class="attachment-thumbnail size-thumbnail" alt="Some very clever alt text" loading="lazy" />',1515 '<img width="%1$d" height="%2$d" src="%3$s" class="attachment-thumbnail size-thumbnail" alt="Some very clever alt text" decoding="async" loading="lazy" />', 1516 1516 $image[1], 1517 1517 $image[2], … … 2248 2248 $respimg_html5 2249 2249 ); 2250 $content_filtered = wp_img_tag_add_decoding_attr( $content_filtered, 'the_content' ); 2250 2251 2251 2252 // Do not add width, height, and loading. … … 2273 2274 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); 2274 2275 $img = wp_img_tag_add_loading_attr( $img, 'test' ); 2276 $img = wp_img_tag_add_decoding_attr( $img, 'the_content' ); 2275 2277 2276 2278 // Replace the src URL. … … 2287 2289 $img = get_image_tag( self::$large_id, '', '', '', 'medium' ); 2288 2290 $img = wp_img_tag_add_loading_attr( $img, 'test' ); 2291 $img = wp_img_tag_add_decoding_attr( $img, 'the_content' ); 2289 2292 $img = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . 'srcset="image2x.jpg 2x" />', $img ); 2290 2293 … … 2334 2337 public function test_wp_filter_content_tags_filter_with_identical_image_tags_custom_attributes() { 2335 2338 $img = get_image_tag( self::$large_id, '', '', '', 'large' ); 2336 $img = str_replace( '<img ', '<img srcset="custom" sizes="custom" loading="custom" ', $img );2339 $img = str_replace( '<img ', '<img srcset="custom" sizes="custom" loading="custom" decoding="custom"', $img ); 2337 2340 $content = "$img\n$img"; 2338 2341 … … 2359 2362 add_filter( 'wp_img_tag_add_width_and_height_attr', '__return_false' ); 2360 2363 add_filter( 'wp_img_tag_add_srcset_and_sizes_attr', '__return_false' ); 2364 add_filter( 'wp_img_tag_add_decoding_attr', '__return_false' ); 2361 2365 2362 2366 add_filter( … … 2461 2465 $respimg_relative 2462 2466 ); 2467 $expected = wp_img_tag_add_decoding_attr( $expected, 'the_content' ); 2463 2468 2464 2469 $actual = wp_filter_content_tags( $unfiltered ); … … 2603 2608 $expected = '<img width="999" height="999" ' . 2604 2609 'src="' . $uploads_url . 'test-image-testsize-999x999.jpg" ' . 2605 'class="attachment-testsize size-testsize" alt="" loading="lazy" ' .2610 'class="attachment-testsize size-testsize" alt="" decoding="async" loading="lazy" ' . 2606 2611 'srcset="' . $uploads_url . 'test-image-testsize-999x999.jpg 999w, ' . $uploads_url . $basename . '-150x150.jpg 150w" ' . 2607 2612 'sizes="(max-width: 999px) 100vw, 999px" />'; … … 2910 2915 2911 2916 $content_unfiltered = sprintf( $content, $img, $img_no_width_height, $img_no_width, $img_no_height ); 2912 $content_filtered = sprintf( $content, $img, $respimg_no_width_height, $img_no_width, $img_no_height);2917 $content_filtered = wp_img_tag_add_decoding_attr( sprintf( $content, $img, $respimg_no_width_height, $img_no_width, $img_no_height ), 'the_content' ); 2913 2918 2914 2919 // Do not add loading, srcset, and sizes. … … 2968 2973 2969 2974 $content_unfiltered = sprintf( $content, $img, $img_xhtml, $img_html5, $img_eager, $img_no_width_height, $iframe, $iframe_eager, $iframe_no_width_height ); 2970 $content_filtered = sprintf( $content, $lazy_img, $lazy_img_xhtml, $lazy_img_html5, $img_eager, $img_no_width_height, $lazy_iframe, $iframe_eager, $iframe_no_width_height);2975 $content_filtered = wp_img_tag_add_decoding_attr( sprintf( $content, $lazy_img, $lazy_img_xhtml, $lazy_img_html5, $img_eager, $img_no_width_height, $lazy_iframe, $iframe_eager, $iframe_no_width_height ), 'the_content' ); 2971 2976 2972 2977 // Do not add width, height, srcset, and sizes. … … 2997 3002 2998 3003 $content_unfiltered = sprintf( $content, $img, $iframe ); 2999 $content_filtered = sprintf( $content, $lazy_img, $lazy_iframe);3004 $content_filtered = sprintf( $content, wp_img_tag_add_decoding_attr( $lazy_img, 'the_content' ), $lazy_iframe, 'the_content' ); 3000 3005 3001 3006 // Do not add srcset and sizes while testing. … … 3015 3020 */ 3016 3021 public function test_wp_filter_content_tags_loading_lazy_opted_out() { 3017 $img = get_image_tag( self::$large_id, '', '', '', 'medium' );3022 $img = wp_img_tag_add_decoding_attr( get_image_tag( self::$large_id, '', '', '', 'medium' ), 'the_content' ); 3018 3023 $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>'; 3019 3024 … … 3479 3484 // Following the threshold of 2, the first two content media elements should not be lazy-loaded. 3480 3485 $content_unfiltered = $img1 . $iframe1 . $img2 . $img3 . $iframe2; 3481 $content_expected = $img1 . $iframe1 . $lazy_img2 . $lazy_img3 . $lazy_iframe2;3486 $content_expected = wp_img_tag_add_decoding_attr( $img1 . $iframe1 . $lazy_img2 . $lazy_img3 . $lazy_iframe2, 'the_content' ); 3482 3487 3483 3488 $wp_query = new WP_Query( array( 'post__in' => array( self::$post_ids['publish'] ) ) );
Note: See TracChangeset
for help on using the changeset viewer.