wp_get_loading_optimization_attributes

wp_get_loading_optimization_attributes

Hook Type: filter

See hook in core

Displaying hooks found in version: wordpress-6.8

apply_filters('wp_get_loading_optimization_attributes') is found 5 times:

  • /wp-includes/media.php line 5990
    5986
    5987
    5988
    5989
    5990
    5991
    5992
    5993
    5994
    5995
    5996
    * The skip is also applicable for `fetchpriority`.
     */
    if ( 'template' === $context ) {
        /** This filter is documented in wp-includes/media.php */
        return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
    }
     
    // For now this function only supports images and iframes.
    if ( 'img' !== $tag_name && 'iframe' !== $tag_name ) {
        /** This filter is documented in wp-includes/media.php */
        return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
  • /wp-includes/media.php line 5996
    5993
    5994
    5995
    5996
    5997
    5998
    5999
    6000
    6001
    6002
    // For now this function only supports images and iframes.
    if ( 'img' !== $tag_name && 'iframe' !== $tag_name ) {
        /** This filter is documented in wp-includes/media.php */
        return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
    }
     
    /*
     * Skip programmatically created images within content blobs as they need to be handled together with the other
     * images within the post content or widget content.
     * Without this clause, they would already be considered within their own context which skews the image count and
  • /wp-includes/media.php line 6012
    6008
    6009
    6010
    6011
    6012
    6013
    6014
    6015
    6016
    6017
    6018
        'widget_text_content' !== $context && doing_filter( 'widget_text_content' ) ||
        'widget_block_content' !== $context && doing_filter( 'widget_block_content' )
    ) {
        /** This filter is documented in wp-includes/media.php */
        return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
     
    }
     
    /*
     * Add `decoding` with a value of "async" for every image unless it has a
     * conflicting `decoding` attribute already present.
  • /wp-includes/media.php line 6031
    6028
    6029
    6030
    6031
    6032
    6033
    6034
    6035
    6036
    6037
    // For any resources, width and height must be provided, to avoid layout shifts.
    if ( ! isset( $attr['width'], $attr['height'] ) ) {
        /** This filter is documented in wp-includes/media.php */
        return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
    }
     
    /*
     * The key function logic starts here.
     */
    $maybe_in_viewport    = null;
  • /wp-includes/media.php line 6176
    6172
    6173
    6174
    6175
    6176
    6177
    6178
    6179
    6180
    6181
    6182
         * @param string $tag_name      The tag name.
         * @param array  $attr          Array of the attributes for the tag.
         * @param string $context       Context for the element for which the loading optimization attribute is requested.
         */
        return apply_filters( 'wp_get_loading_optimization_attributes', $loading_attrs, $tag_name, $attr, $context );
    }
     
    /**
     * Gets the threshold for how many of the first content media elements to not lazy-load.
     *
     * This function runs the {@see 'wp_omit_loading_attr_threshold'} filter, which uses a default threshold value of 3.