// for IE browser - object fit property if ('objectFit' in document.documentElement.style === false) { $('.rec-post-wrap img.hs-featured-image').each(function(){ var w = $(this).width(); var h = $(this).height(); var s = $(this).attr('src'); var final = 'data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'' + w + '\' height=\'' + h + '\'%3E%3C/svg%3E'; $(this).css('background','url('+s+') no-repeat 50% center \/cover'); $(this).attr('src',final); }); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter