Created
November 30, 2015 06:39
-
-
Save angusfretwell/e4266af12a328d1e15d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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