Skip to content

Instantly share code, notes, and snippets.

@bazzooka
Last active December 25, 2015 04:09
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 bazzooka/6915070 to your computer and use it in GitHub Desktop.
Save bazzooka/6915070 to your computer and use it in GitHub Desktop.
Replace each images of the document with colored block. Each block contain it's size. Usefull to work without images but with blocks sizes
function revealSizes() {
$('img').each(function() {
var w = $(this).width(), h = $(this).height(), c = (Math.random() * 0xFFFFFF << 0).toString(16), classes = $(this).attr('class');
var div = $('<div />').css({
background: '#'+c,
fontSize: '200%'
}).width(w).height(h).addClass(classes).html(w+'x'+h);
$(this).replaceWith(div);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment