Filter hook 'pre_wp_get_loading_optimization_attributes'

in WP Core File wp-includes/media.php at line 5982

View Source

pre_wp_get_loading_optimization_attributes

Filter Hook
Description
Filters whether to short-circuit loading optimization attributes. Returning an array from the filter will effectively short-circuit the loading of optimization attributes, returning that value instead.

Hook Information

File Location wp-includes/media.php View on GitHub
Hook Type Filter
Line Number 5982

Hook Parameters

Type Name Description
array|false $loading_attrs False by default, or array of loading optimization attributes to short-circuit.
string $tag_name The tag name.
array $attr Array of the attributes for the tag.
string $context Context for the element for which the loading optimization attribute is requested.

Usage Examples

Basic Usage
<?php
// Hook into pre_wp_get_loading_optimization_attributes
add_filter('pre_wp_get_loading_optimization_attributes', 'my_custom_filter', 10, 4);

function my_custom_filter($loading_attrs, $tag_name, $attr, $context) {
    // Your custom filtering logic here
    return $loading_attrs;
}

Source Code Context

wp-includes/media.php:5982 - How this hook is used in WordPress core
<?php
5977  	 * @param array|false $loading_attrs False by default, or array of loading optimization attributes to short-circuit.
5978  	 * @param string      $tag_name      The tag name.
5979  	 * @param array       $attr          Array of the attributes for the tag.
5980  	 * @param string      $context       Context for the element for which the loading optimization attribute is requested.
5981  	 */
5982  	$loading_attrs = apply_filters( 'pre_wp_get_loading_optimization_attributes', false, $tag_name, $attr, $context );
5983  
5984  	if ( is_array( $loading_attrs ) ) {
5985  		return $loading_attrs;
5986  	}
5987  

PHP Documentation

<?php
/**
	 * Filters whether to short-circuit loading optimization attributes.
	 *
	 * Returning an array from the filter will effectively short-circuit the loading of optimization attributes,
	 * returning that value instead.
	 *
	 * @since 6.4.0
	 *
	 * @param array|false $loading_attrs False by default, or array of loading optimization attributes to short-circuit.
	 * @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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/media.php
Related Hooks

Related hooks will be displayed here in future updates.