Home › Forums › Basel support forum › Thumbnail issue on WC mails › Reply To: Thumbnail issue on WC mails
December 10, 2018 at 9:18 am
#95077
Artem Temos
Keymaster
Try to add the following PHP code snippet to the child theme functions.php file to fix this
function basel_lazy_loading_init( $force_init ) {
if ( ( ( ! basel_get_opt( 'lazy_loading' ) || is_admin() ) && ! $force_init ) ) {
return;
}
// Used for product categories images for example.
add_filter('basel_attachment', 'basel_lazy_attachment_replace', 10, 3);
// Used for instagram images.
add_filter('basel_image', 'basel_lazy_image_standard', 10, 1);
// Used for avatar images.
add_filter( 'get_avatar', 'basel_lazy_avatar_image', 10 );
// Images generated by WPBakery functions
add_filter('vc_wpb_getimagesize', 'basel_lazy_image', 10, 3);
// Products, blog, a lot of other standard wordpress images
add_filter('wp_get_attachment_image_attributes', 'basel_lazy_attributes', 10, 3);
}
add_action( 'init', 'basel_lazy_loading_init', 120 );
function basel_lazy_loading_deinit( $force_deinit = false ) {
if ( basel_get_opt( 'lazy_loading' ) && ! $force_deinit ) {
return;
}
remove_filter( 'basel_attachment', 'basel_lazy_attachment_replace', 10, 3) ;
remove_filter( 'get_avatar', 'basel_lazy_avatar_image', 10 );
remove_filter( 'basel_image', 'basel_lazy_image_standard', 10, 1 );
remove_filter( 'vc_wpb_getimagesize', 'basel_lazy_image', 10, 3 );
remove_filter( 'wp_get_attachment_image_attributes', 'basel_lazy_attributes', 10, 3 );
}
add_action( 'woocommerce_email_before_order_table', function(){
basel_lazy_loading_deinit(true);
}, 20 );
add_action( 'woocommerce_email_after_order_table', function(){
basel_lazy_loading_init(true);
}, 20 );