Skip to content

Instantly share code, notes, and snippets.

@angusfretwell
Created November 30, 2015 06:39
Show Gist options
  • Save angusfretwell/e4266af12a328d1e15d2 to your computer and use it in GitHub Desktop.
Save angusfretwell/e4266af12a328d1e15d2 to your computer and use it in GitHub Desktop.
const pixel = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
if (!Modernizr.testProp('objectFit')) {
const $images = $('.js-object-fit--cover');
$images.each((index, element) => {
const $image = $(element);
$image.css('background-image', `url(${$image.attr('src')})`);
$image.css('background-size', 'cover');
$image.css('background-position', 'center center');
$image.attr('src', pixel);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment