woocommerce_product_image_loading_attr
Filters the loading attribute for product images.
Allowed values are 'lazy', 'eager', and 'auto'. Any other value will result in default browser behavior.
Usage
add_filter( 'woocommerce_product_image_loading_attr', 'wp_kama_woocommerce_product_image_loading_attr_filter', 10, 2 );
/**
* Function for `woocommerce_product_image_loading_attr` filter-hook.
*
* @param string $loading_attr The loading attribute.
* @param int $image_id Target image ID.
*
* @return string
*/
function wp_kama_woocommerce_product_image_loading_attr_filter( $loading_attr, $image_id ){
// filter...
return $loading_attr;
}
- $loading_attr(string)
- The loading attribute.
Default: 'lazy' - $image_id(int)
- Target image ID.
Changelog
| Since 10.6.0 | Introduced. |
Where the hook is called
woocommerce_product_image_loading_attr
woocommerce/src/Blocks/BlockTypes/ProductImage.php 190-194
$loading_attr = apply_filters( 'woocommerce_product_image_loading_attr', 'lazy', $target_image_id, );