wp_get_loading_optimization_attributes

wp_get_loading_optimization_attributes

Hook Type: filter

See hook in core

Displaying hooks found in version: wordpress-6.5.3

apply_filters('wp_get_loading_optimization_attributes') is found 5 times:

  • /wp-includes/media.php line 5752
    	 * 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 5758
     
    	// 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 5774
    		'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 5793
     
    	// 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 5938
    	 * @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.