Make WordPress Core


Ignore:
Timestamp:
06/09/2022 04:19:39 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Media: Some documentation and test improvements for wp_img_tag_add_decoding_attr():

  • Add a @since note for the decoding attribute in wp_get_attachment_image().
  • Adjust wp_img_tag_add_decoding_attr() DocBlocks per the documentation standards.
  • Wrap some long sprintf() calls in unit tests for better readability. In at least one case, the_content was unnecessarily passed to sprintf() as an extra (unused) parameter.

Follow-up to [53480].

See #53232.

File:
1 edited

Legend:

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

    r53480 r53481  
    10041004 * @since 4.4.0 The `$srcset` and `$sizes` attributes were added.
    10051005 * @since 5.5.0 The `$loading` attribute was added.
     1006 * @since 6.1.0 The `$decoding` attribute was added.
    10061007 *
    10071008 * @param int          $attachment_id Image attachment ID.
     
    19441945
    19451946/**
    1946  * Add `decoding` attribute to an `img` HTML tag.
     1947 * Adds `decoding` attribute to an `img` HTML tag.
    19471948 *
    19481949 * The `decoding` attribute allows developers to indicate whether the
     
    19691970     * @since 6.1.0
    19701971     *
    1971      * @param string|false|null $value   The `decoding` attribute value. Returning a falsey value will result in
    1972      *                                   the attribute being omitted for the image. Otherwise, it may be:
    1973      *                                   'async' (default), 'sync', or 'auto'.
     1972     * @param string|false|null $value   The `decoding` attribute value. Returning a falsey value
     1973     *                                   will result in the attribute being omitted for the image.
     1974     *                                   Otherwise, it may be: 'async' (default), 'sync', or 'auto'.
    19741975     * @param string            $image   The HTML `img` tag to be filtered.
    1975      * @param string            $context Additional context about how the function was called or where the img tag is.
     1976     * @param string            $context Additional context about how the function was called
     1977     *                                   or where the img tag is.
    19761978     */
    19771979    $value = apply_filters( 'wp_img_tag_add_decoding_attr', 'async', $image, $context );
     1980
    19781981    if ( in_array( $value, array( 'async', 'sync', 'auto' ), true ) ) {
    19791982        $image = str_replace( '<img ', '<img decoding="' . esc_attr( $value ) . '" ', $image );
Note: See TracChangeset for help on using the changeset viewer.