Skip to content

Instantly share code, notes, and snippets.

@fimdomeio
Last active August 29, 2015 14:12
Show Gist options
  • Save fimdomeio/63b34c80c522eb7dc0e6 to your computer and use it in GitHub Desktop.
Save fimdomeio/63b34c80c522eb7dc0e6 to your computer and use it in GitHub Desktop.
Quick hack to show current image dimentions
$(window).on('load', function() {
var el = 'img';
getElSizes(el);
$(window).on('resize orientationChanged', function() {
$('.elSize').remove();
getElSizes(el);
});
});
var getElSizes = function(el){
var allEL = $(el);
allEL.each(function(index){
var w = $(this).width();
var h = $(this).height();
var l = $(this).position().left;
var t = $(this).position().top;
$(this).css('outline', '1px solid #bb2222');
var dimensionsEl = '<div class="elSize" style="background: #bb2222; color: white; position: absolute; left:'+l+'px; top:'+t+'px;">'+w+' x '+h+'</div>';
$(this).after( dimensionsEl );
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment