/**
* Global Optimization for Elementor + Dressy Theme Featured Images
* Removes lazy loading and adds fetchpriority="high" across all products
*/
add_filter( 'wp_get_attachment_image_attributes', 'elementor_dressy_featured_image_optimization', 99, 3 );
function elementor_dressy_featured_image_optimization( $attributes, $attachment, $size ) {
// Only target product pages
if ( is_product() ) {
// Elementor uses sizes like 'large', 'full', or theme-defined sizes for its main showcase slider
// This targets the primary images while leaving sidebar/upsell thumbnails alone
if ( in_array( $size, ['large', 'full', 'woocommerce_single', 'shop_single'] ) ) {
// 1. Force native eager loading and priority
$attributes['loading'] = 'eager';
$attributes['fetchpriority'] = 'high';
// 2. Inject global exclusion classes recognized by BerqWP
if ( isset( $attributes['class'] ) ) {
$attributes['class'] .= ' skip-lazy no-lazyload bq-no-lazy';
} else {
$attributes['class'] = 'skip-lazy no-lazyload bq-no-lazy';
}
}
}
return $attributes;
}
Your cart is currently empty!
New in store