For any one else getting here after trying to disable the Woodmart Lazy loading (which does not respect the wp_lazy_loading_enabled
filter, unfortunately), you can do this by calling a dedicated function they created for this woodmart_lazy_loading_deinit()
:
if ( function_exists( 'woodmart_lazy_loading_deinit' ) ) {
woodmart_lazy_loading_deinit( true ); // true to "force deinit"
}
if you need to ‘clean up’ after yourself, you can activate it in a similar manner with the woodmart_lazy_loading_init()
function:
if ( function_exists( 'woodmart_lazy_loading_init' ) ) {
woodmart_lazy_loading_init( true ); // true to "force init"
}
They add several filters, but for the product images the relevant one is wp_get_attachment_image_attributes
:
function woodmart_lazy_loading_init( $force_init = false ) {
if ( ( ( ! woodmart_get_opt( 'lazy_loading' ) || is_admin() ) && ! $force_init ) ) {
return;
}
// Used for product categories images for example.
add_filter('woodmart_attachment', 'woodmart_lazy_attachment_replace', 10, 3);
// Used for avatar images.
add_filter( 'get_avatar', 'woodmart_lazy_avatar_image', 10 );
// Used for instagram images.
add_filter('woodmart_image', 'woodmart_lazy_image_standard', 10, 1);
// Images generated by WPBakery functions
add_filter('vc_wpb_getimagesize', 'woodmart_lazy_image', 10, 3);
// Products, blog, a lot of other standard wordpress images
add_filter('wp_get_attachment_image_attributes', 'woodmart_lazy_attributes', 10, 3);
}