wp-includes/media.php:6207Determines whether to add fetchpriority='high' to loading attributes.
$loading_attrsarray$tag_namestring$attrarrayarrayOne hook fires while wp_maybe_add_fetchpriority_high_attr() runs, in this order:
Filters the minimum square-pixels threshold for an image to be eligible as the high-priority image.
function wp_maybe_add_fetchpriority_high_attr( $loading_attrs, $tag_name, $attr ) { // For now, adding `fetchpriority="high"` is only supported for images. if ( 'img' !== $tag_name ) { return $loading_attrs; } if ( isset( $attr['fetchpriority'] ) ) { /* * While any `fetchpriority` value could be set in `$loading_attrs`, * for consistency we only do it for `fetchpriority="high"` since that * is the only possible value that WordPress core would apply on its * own. */ if ( 'high' === $attr['fetchpriority'] ) { $loading_attrs['fetchpriority'] = 'high'; wp_high_priority_element_flag( false ); } return $loading_attrs; } // Lazy-loading and `fetchpriority="high"` are mutually exclusive. if ( isset( $loading_attrs['loading'] ) && 'lazy' === $loading_attrs['loading'] ) { return $loading_attrs; } if ( ! wp_high_priority_element_flag() ) { return $loading_attrs; } /** * Filters the minimum square-pixels threshold for an image to be eligible as the high-priority image. * * @since 6.3.0 * * @param int $threshold Minimum square-pixels threshold. Default 50000. */ $wp_min_priority_img_pixels = apply_filters( 'wp_min_priority_img_pixels', 50000 ); if ( $wp_min_priority_img_pixels <= $attr['width'] * $attr['height'] ) { $loading_attrs['fetchpriority'] = 'high'; wp_high_priority_element_flag( false ); } return $loading_attrs;}Introduced in 6.3.0. 3 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$loading_attrs retyped from array to untyped.verified against source$attr retyped from array to untyped.verified against sourcearray to array<string,.verified against sourcesrc/wp-includes/media.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.