Skip to content

Instantly share code, notes, and snippets.

@KaiserEMP
Last active January 29, 2018 11:49
Show Gist options
  • Select an option

  • Save KaiserEMP/ea2b4438c0a7c3d808ad4462827e30fc to your computer and use it in GitHub Desktop.

Select an option

Save KaiserEMP/ea2b4438c0a7c3d808ad4462827e30fc to your computer and use it in GitHub Desktop.
if ( ! Modernizr.objectfit ) {
$('.eda-module-type-social .tab_content_inner div a[rel="instagram-feed"]').each(function () {
var $container = $(this),
imgUrl = $container.find('img').prop('src');
if (imgUrl) {
$container
.css('backgroundImage', 'url(' + imgUrl + ')')
.addClass('compat-object-fit');
}
});
}
.eda-module-type-social .tab_content .tab_content_inner div a[rel="instagram-feed"] {
width: 100%;
height: 270px;
display: block;
margin-bottom: 12px;
img {
width: 100vh;
height: 270px;
object-fit: cover;
}
&.compat-object-fit {
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
img { // hide image if object fit is not supported - opacity to 0 for the link area
opacity: 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment