$(document).ready(function () {
    
    let imgWrap = $('.products-list-v2 .card__img-wrap');
    let img = $('.products-list-v2 .card__img-v2');
    
    square();

    img.height(function () {
        if (Math.round($(this).height()) > Math.round($(this).width())) {
            $(this).height('99.9%'); //fix for ie
        } else if ((Math.round($(this).height()) < Math.round($(this).width()))){
            $(this).width('99.9%'); // fix for ie
        } else {
            $(this).width('99.9%'); // fix for ie
            $(this).height('99.9%'); // fix for ie
        }
    });

    function square() {
        let width = imgWrap.width();
        imgWrap.height(width);
    }

    $(window).on('resize', square);
});
