Last active
August 29, 2015 14:12
-
-
Save fimdomeio/63b34c80c522eb7dc0e6 to your computer and use it in GitHub Desktop.
Quick hack to show current image dimentions
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
$(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