I have resize image function according to the container, but if I resize the browser window the else statement is working earlier on 784xp. When I resize in resposive mode from the Device Toolbar ( Ctrl + SHIFT + M ) is ok. Is that normal or if not what to change in my function ? The other problem is that <768px the else is not working before refresh.
$(document).ready(resizeImg);
$(window).resize(resizeImg);
    function resizeImg(){
        var img = $('.box-image');
        var box = $('.box');
        var boxHeight = $(box).innerHeight();
        if ($(window).width() > 767) {
            $(img).height(boxHeight)
        }
        else {
            $(img).css({ 'height' : 'auto' });
        }
    }