/** * Created by Simon on 28.04.2017. */ function modernizeObjectFit($selector) { // Object-fit if (!Modernizr.objectfit) { jQuery($selector).each(function () { var $container = jQuery(this), imgUrl = $container.find('img').prop('src'); if (imgUrl) { $container .css('backgroundImage', 'url(' + imgUrl + ')') .addClass('compat-object-fit'); } }); jQuery($selector + " img").each(function () { jQuery(this).css('opacity', '0'); }); } }