Last active
August 29, 2015 13:59
-
-
Save jeffisabelle/10577507 to your computer and use it in GitHub Desktop.
change img to div with background-image (for covered thumbnails)
This file contains 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
$('img.tocover').each(function(i, elem) { | |
var img = $(elem); | |
var div = $("<div />").css({ | |
"background": "url(" + img.attr("src") + ") no-repeat", | |
"background-size": "cover", | |
"width": "150px", | |
"height": "150px", | |
"margin": "5px" | |
}) | |
img.replaceWith(div); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment