Skip to content

Instantly share code, notes, and snippets.

@jeffisabelle
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffisabelle/10577507 to your computer and use it in GitHub Desktop.
Save jeffisabelle/10577507 to your computer and use it in GitHub Desktop.
change img to div with background-image (for covered thumbnails)
$('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