Make WordPress Core

Ticket #53232: 53232.1.diff

File 53232.1.diff, 23.6 KB (added by westonruter, 4 years ago)
  • src/wp-includes/media.php

    diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
    index ce05298b50..c380505762 100644
    a b function wp_get_attachment_image( $attachment_id, $size = 'thumbnail', $icon = f 
    10761076                        }
    10771077                }
    10781078
     1079                $attr['decoding'] = 'async';
     1080
    10791081                /**
    10801082                 * Filters the list of attachment image attributes.
    10811083                 *
    function wp_filter_content_tags( $content, $context = null ) { 
    18421844                                $filtered_image = wp_img_tag_add_loading_attr( $filtered_image, $context );
    18431845                        }
    18441846
     1847                        // Add 'decoding=async' attribute unless a 'decoding' attribute is already present.
     1848                        if ( false === strpos( $filtered_image, ' decoding=' ) ) {
     1849                                $filtered_image = wp_img_tag_add_decoding_async_attr( $filtered_image );
     1850                        }
     1851
    18451852                        if ( $filtered_image !== $match[0] ) {
    18461853                                $content = str_replace( $match[0], $filtered_image, $content );
    18471854                        }
    function wp_img_tag_add_loading_attr( $image, $context ) { 
    19101917        return $image;
    19111918}
    19121919
     1920/**
     1921 * Adds `decoding=async` attribute to an `img` HTML tag.
     1922 *
     1923 * @since 5.9.0
     1924 *
     1925 * @param string $image   The HTML `img` tag where the attribute should be added.
     1926 * @return string Converted `img` tag with `decoding=async` attribute added.
     1927 */
     1928function wp_img_tag_add_decoding_async_attr( $image ) {
     1929        return str_replace( '<img ', '<img decoding="async" ', $image );
     1930}
     1931
    19131932/**
    19141933 * Adds `width` and `height` attributes to an `img` HTML tag.
    19151934 *
  • src/wp-includes/pluggable.php

    diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php
    index e30fad1808..7206230aee 100644
    a b if ( ! function_exists( 'get_avatar' ) ) : 
    26752675                        'force_display' => false,
    26762676                        'loading'       => null,
    26772677                        'extra_attr'    => '',
     2678                        'decoding'      => 'async',
    26782679                );
    26792680
    26802681                if ( wp_lazy_loading_enabled( 'img', 'get_avatar' ) ) {
    if ( ! function_exists( 'get_avatar' ) ) : 
    27622763                        $extra_attr .= "loading='{$loading}'";
    27632764                }
    27642765
     2766                if ( isset( $args['decoding'] ) && in_array( $args['decoding'], array( 'async', 'sync', 'auto' ) ) && ! preg_match( '/\bdecoding\s*=/', $extra_attr ) ) {
     2767                        if ( ! empty( $extra_attr ) ) {
     2768                                $extra_attr .= ' ';
     2769                        }
     2770                        $extra_attr .= "decoding='{$args['decoding']}'";
     2771                }
     2772
    27652773                $avatar = sprintf(
    27662774                        "<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>",
    27672775                        esc_attr( $args['alt'] ),
  • tests/phpunit/tests/media.php

    diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php
    index 2781378c86..9921d6cf4f 100644
    a b CAP; 
    6767<img src="pic.jpg" id='anId' alt="pic"/>
    6868CAP;
    6969                $this->img_name          = 'image.jpg';
    70                 $this->img_url           = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $this->img_name;
     70                $this->img_url           = WP_CONTENT_URL . '/uploads/' . $this->img_name;
    7171                $this->img_html          = '<img src="' . $this->img_url . '"/>';
    7272                $this->img_meta          = array(
    7373                        'width'  => 100,
    https://w.org</a>', 
    430430                                'post_type'      => 'attachment',
    431431                                'post_parent'    => 0,
    432432                                'post_mime_type' => 'image/jpeg',
    433                                 'guid'           => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/test-image.jpg',
     433                                'guid'           => WP_CONTENT_URL . '/uploads/test-image.jpg',
    434434                        )
    435435                );
    436436
    https://w.org</a>', 
    524524                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
    525525                        wp_update_attachment_metadata( $attachment_id, $metadata );
    526526                        $ids1[]      = $attachment_id;
    527                         $ids1_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
     527                        $ids1_srcs[] = WP_CONTENT_URL . '/uploads/' . "image$i.jpg";
    528528                }
    529529
    530530                $ids2      = array();
    https://w.org</a>', 
    541541                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
    542542                        wp_update_attachment_metadata( $attachment_id, $metadata );
    543543                        $ids2[]      = $attachment_id;
    544                         $ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
     544                        $ids2_srcs[] = WP_CONTENT_URL . '/uploads/' . "image$i.jpg";
    545545                }
    546546
    547547                $ids1_joined = implode( ',', $ids1 );
    BLOB; 
    605605                        )
    606606                );
    607607                $expected_srcs = array(
    608                         'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/test.jpg',
     608                        WP_CONTENT_URL . '/uploads/test.jpg',
    609609                );
    610610
    611611                // Set the global $post context to the other post.
    BLOB; 
    640640                        )
    641641                );
    642642                $expected_srcs = array(
    643                         'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/test.jpg',
     643                        WP_CONTENT_URL . '/uploads/test.jpg',
    644644                );
    645645
    646646                $galleries = get_post_galleries( $post_id_two, false );
    BLOB; 
    674674                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
    675675                        wp_update_attachment_metadata( $attachment_id, $metadata );
    676676                        $ids1[]      = $attachment_id;
    677                         $ids1_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
     677                        $ids1_srcs[] = WP_CONTENT_URL . '/uploads/' . "image$i.jpg";
    678678                }
    679679
    680680                $ids2      = array();
    BLOB; 
    691691                        $metadata      = array_merge( array( 'file' => "image$i.jpg" ), $this->img_meta );
    692692                        wp_update_attachment_metadata( $attachment_id, $metadata );
    693693                        $ids2[]      = $attachment_id;
    694                         $ids2_srcs[] = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . "image$i.jpg";
     694                        $ids2_srcs[] = WP_CONTENT_URL . '/uploads/' . "image$i.jpg";
    695695                }
    696696
    697697                $ids1_joined = implode( ',', $ids1 );
    VIDEO; 
    10871087                        )
    10881088                );
    10891089
    1090                 $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path;
     1090                $image_url = WP_CONTENT_URL . '/uploads/' . $image_path;
    10911091                $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) );
    10921092        }
    10931093
    VIDEO; 
    11051105                        )
    11061106                );
    11071107
    1108                 $image_url = 'https://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path;
     1108                $image_url = set_url_scheme( WP_CONTENT_URL, 'https' ) . '/uploads/' . $image_path;
    11091109                $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) );
    11101110        }
    11111111
    VIDEO; 
    11331133                        )
    11341134                );
    11351135
    1136                 $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path_upper_case;
     1136                $image_url = WP_CONTENT_URL . '/uploads/' . $image_path_upper_case;
    11371137                $this->assertSame( $attachment_id_upper_case, attachment_url_to_postid( $image_url ) );
    11381138        }
    11391139
    EOF; 
    13701370        function test_wp_get_attachment_image_defaults() {
    13711371                $image    = image_downsize( self::$large_id, 'thumbnail' );
    13721372                $expected = sprintf(
    1373                         '<img width="%1$d" height="%2$d" src="%3$s" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" />',
     1373                        '<img width="%1$d" height="%2$d" src="%3$s" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" decoding="async" />',
    13741374                        $image[1],
    13751375                        $image[2],
    13761376                        $image[0]
    EOF; 
    14081408
    14091409                $image    = image_downsize( self::$large_id, 'thumbnail' );
    14101410                $expected = sprintf(
    1411                         '<img width="%1$d" height="%2$d" src="%3$s" class="attachment-thumbnail size-thumbnail" alt="Some very clever alt text" loading="lazy" />',
     1411                        '<img width="%1$d" height="%2$d" src="%3$s" class="attachment-thumbnail size-thumbnail" alt="Some very clever alt text" loading="lazy" decoding="async" />',
    14121412                        $image[1],
    14131413                        $image[2],
    14141414                        $image[0]
    EOF; 
    15281528
    15291529                $year_month      = gmdate( 'Y/m' );
    15301530                $image_meta      = wp_get_attachment_metadata( self::$large_id );
    1531                 $uploads_dir_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
     1531                $uploads_dir_url = WP_CONTENT_URL . '/uploads/';
    15321532
    15331533                // Set up test cases for all expected size names.
    15341534                $intermediates = array( 'medium', 'medium_large', 'large', 'full' );
    EOF; 
    15821582                $id       = self::factory()->attachment->create_upload_object( $filename );
    15831583
    15841584                $image_meta      = wp_get_attachment_metadata( $id );
    1585                 $uploads_dir_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
     1585                $uploads_dir_url = WP_CONTENT_URL . '/uploads/';
    15861586
    15871587                // Set up test cases for all expected size names.
    15881588                $intermediates = array( 'medium', 'medium_large', 'large', 'full' );
    EOF; 
    16671667
    16681668                $year_month      = gmdate( 'Y/m' );
    16691669                $image_meta      = wp_get_attachment_metadata( self::$large_id );
    1670                 $uploads_dir_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
     1670                $uploads_dir_url = WP_CONTENT_URL . '/uploads/';
    16711671
    16721672                // Set up test cases for all expected size names.
    16731673                $intermediates = array( 'medium', 'medium_large', 'large', 'full' );
    EOF; 
    17441744        function test_wp_calculate_image_srcset_ratio_variance() {
    17451745                // Mock data for this test.
    17461746                $size_array = array( 218, 300 );
    1747                 $image_src  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-768x1055-218x300.png';
     1747                $image_src  = WP_CONTENT_URL . '/uploads/2015/12/test-768x1055-218x300.png';
    17481748                $image_meta = array(
    17491749                        'width'  => 768,
    17501750                        'height' => 1055,
    EOF; 
    17771777                        ),
    17781778                );
    17791779
    1780                 $uploads_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/';
     1780                $uploads_url = WP_CONTENT_URL . '/uploads/2015/12/';
    17811781
    17821782                $expected_srcset = $uploads_url . 'test-768x1055-218x300.png 218w, ' .
    17831783                        $uploads_url . 'test-768x1055-600x824.png 600w, ' .
    EOF; 
    17931793        function test_wp_calculate_image_srcset_include_src() {
    17941794                // Mock data for this test.
    17951795                $size_array = array( 2000, 1000 );
    1796                 $image_src  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test.png';
     1796                $image_src  = WP_CONTENT_URL . '/uploads/2015/12/test.png';
    17971797                $image_meta = array(
    17981798                        'width'  => 2000,
    17991799                        'height' => 1000,
    EOF; 
    18261826                        ),
    18271827                );
    18281828
    1829                 $uploads_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/';
     1829                $uploads_url = WP_CONTENT_URL . '/uploads/2015/12/';
    18301830
    18311831                $expected_srcset = $uploads_url . 'test.png 2000w, ' .
    18321832                        $uploads_url . 'test-300x150.png 300w, ' .
    EOF; 
    18411841         */
    18421842        function test_wp_calculate_image_srcset_corrupted_image_meta() {
    18431843                $size_array = array( 300, 150 );
    1844                 $image_src  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-300x150.png';
     1844                $image_src  = WP_CONTENT_URL . '/uploads/2015/12/test-300x150.png';
    18451845                $image_meta = array(
    18461846                        'width'  => 1600,
    18471847                        'height' => 800,
    EOF; 
    18751875                );
    18761876
    18771877                $srcset = array(
    1878                         300  => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-300x150.png 300w',
    1879                         768  => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-768x384.png 768w',
    1880                         1024 => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test-1024x512.png 1024w',
    1881                         1600 => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test.png 1600w',
     1878                        300  => WP_CONTENT_URL . '/uploads/2015/12/test-300x150.png 300w',
     1879                        768  => WP_CONTENT_URL . '/uploads/2015/12/test-768x384.png 768w',
     1880                        1024 => WP_CONTENT_URL . '/uploads/2015/12/test-1024x512.png 1024w',
     1881                        1600 => WP_CONTENT_URL . '/uploads/2015/12/test.png 1600w',
    18821882                );
    18831883
    18841884                // No sizes array.
    EOF; 
    19151915         */
    19161916        function test_wp_calculate_image_srcset_with_spaces_in_filenames() {
    19171917                // Mock data for this test.
    1918                 $image_src  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/test image-300x150.png';
     1918                $image_src  = WP_CONTENT_URL . '/uploads/2015/12/test image-300x150.png';
    19191919                $image_meta = array(
    19201920                        'width'  => 3000,
    19211921                        'height' => 1500,
    EOF; 
    19481948                        ),
    19491949                );
    19501950
    1951                 $uploads_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/2015/12/';
     1951                $uploads_url = WP_CONTENT_URL . '/uploads/2015/12/';
    19521952
    19531953                $expected_srcset = $uploads_url . 'test%20image-300x150.png 300w, ' .
    19541954                        $uploads_url . 'test%20image-768x384.png 768w, ' .
    EOF; 
    19701970                $srcset = wp_get_attachment_image_srcset( self::$large_id, $size_array, $image_meta );
    19711971
    19721972                $year_month  = gmdate( 'Y/m' );
    1973                 $uploads_dir = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
     1973                $uploads_dir = WP_CONTENT_URL . '/uploads/';
    19741974
    19751975                // Set up test cases for all expected size names.
    19761976                $intermediates = array( 'medium', 'medium_large', 'large', 'full' );
    EOF; 
    21442144                        $respimg_xhtml,
    21452145                        $respimg_html5
    21462146                );
     2147                $content_filtered = wp_img_tag_add_decoding_async_attr( $content_filtered );
    21472148
    21482149                // Do not add width, height, and loading.
    21492150                add_filter( 'wp_img_tag_add_width_and_height_attr', '__return_false' );
    EOF; 
    21692170        function test_wp_filter_content_tags_srcset_sizes_wrong() {
    21702171                $img = get_image_tag( self::$large_id, '', '', '', 'medium' );
    21712172                $img = wp_img_tag_add_loading_attr( $img, 'test' );
     2173                $img = wp_img_tag_add_decoding_async_attr( $img );
    21722174
    21732175                // Replace the src URL.
    21742176                $image_wrong_src = preg_replace( '|src="[^"]+"|', 'src="http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/foo.jpg"', $img );
    EOF; 
    21832185                // Generate HTML and add a dummy srcset attribute.
    21842186                $img = get_image_tag( self::$large_id, '', '', '', 'medium' );
    21852187                $img = wp_img_tag_add_loading_attr( $img, 'test' );
     2188                $img = wp_img_tag_add_decoding_async_attr( $img );
    21862189                $img = preg_replace( '|<img ([^>]+) />|', '<img $1 ' . 'srcset="image2x.jpg 2x" />', $img );
    21872190
    21882191                // The content filter should return the image unchanged.
    EOF; 
    22212224                        ),
    22222225                );
    22232226
    2224                 $full_src  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['file'];
    2225                 $large_src = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['sizes']['large']['file'];
     2227                $full_src  = WP_CONTENT_URL . '/uploads/' . $image_meta['file'];
     2228                $large_src = WP_CONTENT_URL . '/uploads/' . $image_meta['sizes']['large']['file'];
    22262229
    22272230                // Test with soft resized size array.
    22282231                $size_array = array( 900, 450 );
    EOF; 
    22792282                        $respimg_https,
    22802283                        $respimg_relative
    22812284                );
     2285                $expected = wp_img_tag_add_decoding_async_attr( $expected );
    22822286
    22832287                $actual = wp_filter_content_tags( $unfiltered );
    22842288
    EOF; 
    23142318                        ),
    23152319                );
    23162320
     2321                $wp_content_path = wp_parse_url( WP_CONTENT_URL, PHP_URL_PATH );
     2322
    23172323                // Test using the large file size.
    23182324                $size_array = array( 1024, 512 );
    2319                 $image_url  = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_meta['sizes']['large']['file'];
     2325                $image_url  = 'http://' . WP_TESTS_DOMAIN . $wp_content_path . '/uploads/' . $image_meta['sizes']['large']['file'];
    23202326
    23212327                $_SERVER['HTTPS'] = 'on';
    23222328
    2323                 $uploads_url = 'https://' . WP_TESTS_DOMAIN . '/wp-content/uploads/';
     2329                $uploads_url = 'https://' . WP_TESTS_DOMAIN . $wp_content_path . '/uploads/';
    23242330
    23252331                $expected = $uploads_url . 'test-1024x512.jpg 1024w, ' .
    23262332                        $uploads_url . 'test-300x150.jpg 300w, ' .
    EOF; 
    24172423
    24182424                $basename    = wp_basename( self::$large_filename, '.jpg' );
    24192425                $year_month  = gmdate( 'Y/m' );
    2420                 $uploads_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $year_month . '/';
     2426                $uploads_url = WP_CONTENT_URL . '/uploads/' . $year_month . '/';
    24212427
    24222428                $expected = '<img width="999" height="999" ' .
    24232429                        'src="' . $uploads_url . 'test-image-testsize-999x999.jpg" ' .
    24242430                        'class="attachment-testsize size-testsize" alt="" loading="lazy" ' .
    24252431                        'srcset="' . $uploads_url . 'test-image-testsize-999x999.jpg 999w, ' . $uploads_url . $basename . '-150x150.jpg 150w" ' .
    2426                         'sizes="(max-width: 999px) 100vw, 999px" />';
     2432                        'sizes="(max-width: 999px) 100vw, 999px" decoding="async" />';
    24272433
    24282434                $actual = wp_get_attachment_image( self::$large_id, 'testsize' );
    24292435
    EOF; 
    27282734                        %4$s';
    27292735
    27302736                $content_unfiltered = sprintf( $content, $img, $img_no_width_height, $img_no_width, $img_no_height );
    2731                 $content_filtered   = sprintf( $content, $img, $respimg_no_width_height, $img_no_width, $img_no_height );
     2737                $content_filtered   = wp_img_tag_add_decoding_async_attr( sprintf( $content, $img, $respimg_no_width_height, $img_no_width, $img_no_height ) );
    27322738
    27332739                // Do not add loading, srcset, and sizes.
    27342740                add_filter( 'wp_img_tag_add_loading_attr', '__return_false' );
    EOF; 
    27862792                        %8$s';
    27872793
    27882794                $content_unfiltered = sprintf( $content, $img, $img_xhtml, $img_html5, $img_eager, $img_no_width_height, $iframe, $iframe_eager, $iframe_no_width_height );
    2789                 $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 );
     2795                $content_filtered   = wp_img_tag_add_decoding_async_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 ) );
    27902796
    27912797                // Do not add width, height, srcset, and sizes.
    27922798                add_filter( 'wp_img_tag_add_width_and_height_attr', '__return_false' );
    EOF; 
    28152821                        %2$s';
    28162822
    28172823                $content_unfiltered = sprintf( $content, $img, $iframe );
    2818                 $content_filtered   = sprintf( $content, $lazy_img, $lazy_iframe );
     2824                $content_filtered   = sprintf( $content, wp_img_tag_add_decoding_async_attr( $lazy_img ), $lazy_iframe );
    28192825
    28202826                // Do not add srcset and sizes while testing.
    28212827                add_filter( 'wp_img_tag_add_srcset_and_sizes_attr', '__return_false' );
    EOF; 
    28332839         * @ticket 50756
    28342840         */
    28352841        function test_wp_filter_content_tags_loading_lazy_opted_out() {
    2836                 $img    = get_image_tag( self::$large_id, '', '', '', 'medium' );
     2842                $img    = wp_img_tag_add_decoding_async_attr( get_image_tag( self::$large_id, '', '', '', 'medium' ) );
    28372843                $iframe = '<iframe src="https://www.example.com" width="640" height="360"></iframe>';
    28382844
    28392845                $content = '
    EOF; 
    33003306
    33013307                // Following the threshold of 2, the first two content media elements should not be lazy-loaded.
    33023308                $content_unfiltered = $img1 . $iframe1 . $img2 . $img3 . $iframe2;
    3303                 $content_expected   = $img1 . $iframe1 . $lazy_img2 . $lazy_img3 . $lazy_iframe2;
     3309                $content_expected   = wp_img_tag_add_decoding_async_attr( $img1 . $iframe1 . $lazy_img2 . $lazy_img3 . $lazy_iframe2 );
    33043310
    33053311                $wp_query               = new WP_Query( array( 'post__in' => array( self::$post_ids['publish'] ) ) );
    33063312                $wp_the_query           = $wp_query;
  • tests/phpunit/tests/media/getAdjacentImageLink.php

    diff --git a/tests/phpunit/tests/media/getAdjacentImageLink.php b/tests/phpunit/tests/media/getAdjacentImageLink.php
    index 265c5d6bb2..db32b57bfa 100644
    a b class Tests_Media_GetAdjacentImageLink extends WP_Test_Adjacent_Image_Link_TestC 
    3232                        'when has previous link'           => array(
    3333                                'current_attachment_index'  => 3,
    3434                                'expected_attachment_index' => 2,
    35                                 'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="http://example.org/wp-content/uploads/image2.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" /></a>',
     35                                'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="' . WP_CONTENT_URL . '/uploads/image2.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" decoding="async" /></a>',
    3636                        ),
    3737                        'with text when has previous link' => array(
    3838                                'current_attachment_index'  => 3,
    class Tests_Media_GetAdjacentImageLink extends WP_Test_Adjacent_Image_Link_TestC 
    4343                        'when has next link'               => array(
    4444                                'current_attachment_index'  => 4,
    4545                                'expected_attachment_index' => 5,
    46                                 'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="http://example.org/wp-content/uploads/image5.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" /></a>',
     46                                'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="' . WP_CONTENT_URL . '/uploads/image5.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" decoding="async" /></a>',
    4747                                'args'                      => array( 'prev' => false ),
    4848                        ),
    4949                        'with text when has next link'     => array(
  • tests/phpunit/tests/media/getNextImageLink.php

    diff --git a/tests/phpunit/tests/media/getNextImageLink.php b/tests/phpunit/tests/media/getNextImageLink.php
    index feb5fdbdf7..dbec6f5f2c 100644
    a b class Tests_Media_GetNextImageLink extends WP_Test_Adjacent_Image_Link_TestCase 
    3131                        'when has next link'           => array(
    3232                                'current_attachment_index'  => 4,
    3333                                'expected_attachment_index' => 5,
    34                                 'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="http://example.org/wp-content/uploads/image5.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" /></a>',
     34                                'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="' . WP_CONTENT_URL . '/uploads/image5.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" decoding="async" /></a>',
    3535                        ),
    3636                        'with text when has next link' => array(
    3737                                'current_attachment_index'  => 4,
  • tests/phpunit/tests/media/getPreviousImageLink.php

    diff --git a/tests/phpunit/tests/media/getPreviousImageLink.php b/tests/phpunit/tests/media/getPreviousImageLink.php
    index 61763ee3a2..ba06ca9b2d 100644
    a b class Tests_Media_GetPreviousImageLink extends WP_Test_Adjacent_Image_Link_TestC 
    3131                        'when has previous link'           => array(
    3232                                'current_attachment_index'  => 3,
    3333                                'expected_attachment_index' => 2,
    34                                 'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="http://example.org/wp-content/uploads/image2.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" /></a>',
     34                                'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="' . WP_CONTENT_URL . '/uploads/image2.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" decoding="async" /></a>',
    3535                        ),
    3636                        'with text when has previous link' => array(
    3737                                'current_attachment_index'  => 3,
  • tests/phpunit/tests/media/nextImageLink.php

    diff --git a/tests/phpunit/tests/media/nextImageLink.php b/tests/phpunit/tests/media/nextImageLink.php
    index f3ba340b7f..352a842388 100644
    a b class Tests_Media_NextImageLink extends WP_Test_Adjacent_Image_Link_TestCase { 
    3030                        'when has next link'           => array(
    3131                                'current_attachment_index'  => 4,
    3232                                'expected_attachment_index' => 5,
    33                                 'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="http://example.org/wp-content/uploads/image5.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" /></a>',
     33                                'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="' . WP_CONTENT_URL . '/uploads/image5.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" decoding="async" /></a>',
    3434                        ),
    3535                        'with text when has next link' => array(
    3636                                'current_attachment_index'  => 4,
  • tests/phpunit/tests/media/previousImageLink.php

    diff --git a/tests/phpunit/tests/media/previousImageLink.php b/tests/phpunit/tests/media/previousImageLink.php
    index 769d029d89..ffd6309ece 100644
    a b class Tests_Media_PreviousImageLink extends WP_Test_Adjacent_Image_Link_TestCase 
    3030                        'when has previous link'           => array(
    3131                                'current_attachment_index'  => 3,
    3232                                'expected_attachment_index' => 2,
    33                                 'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="http://example.org/wp-content/uploads/image2.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" /></a>',
     33                                'expected'                  => '<a href=\'http://example.org/?attachment_id=%%ID%%\'><img width="1" height="1" src="' . WP_CONTENT_URL . '/uploads/image2.jpg" class="attachment-thumbnail size-thumbnail" alt="" loading="lazy" decoding="async" /></a>',
    3434                        ),
    3535                        'with text when has previous link' => array(
    3636                                'current_attachment_index'  => 3,
OSZAR »