/*
Theme Name:   Xstore child
Theme URI:    https://xstore.8theme.com
Description:  XStore is a multi-purpose theme that offers the ultimate WordPress and WooCommerce synergy, providing a comprehensive, all-in-one solution.
Author:       8theme
Author URI:   https://www.8theme.com
Template:     xstore
Version:      1.0
Text Domain:  xstore-child
Tags: e-commerce, two-columns, left-sidebar, right-sidebar, custom-background, custom-colors, custom-header, custom-menu, custom-logo, featured-images, full-width-template, threaded-comments, accessibility-ready, rtl-language-support, footer-widgets, sticky-post, theme-options, translation-ready, ecommerce, woocommerce, shop, elementor, business, corporate, blog, news, light, dark
*/

add_filter('wp_get_attachment_image_attributes', function($attr){
    if (is_shop() || is_product_category()) {
        $attr['loading'] = 'eager';
        $attr['decoding'] = 'sync';
    }
    return $attr;
});

add_filter('wp_get_attachment_image_attributes', function($attr){
    if (isset($attr['sizes']) && str_contains($attr['sizes'], 'auto')) {
        $attr['sizes'] = '(max-width: 480px) 50vw, 300px';
    }
    return $attr;
});

add_filter('wp_get_attachment_image_attributes', function ($attr) {
    if (is_shop() || is_product_category() || is_product_tag()) {
        $attr['loading']  = 'eager';
        $attr['fetchpriority'] = 'high';
        $attr['decoding'] = 'sync';
    }
    return $attr;
}, 10, 1);


