Skip to content

Instantly share code, notes, and snippets.

@KruegerDesigns
Last active August 29, 2015 14:10
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 KruegerDesigns/8cdbba88f0deeec4736f to your computer and use it in GitHub Desktop.
Save KruegerDesigns/8cdbba88f0deeec4736f to your computer and use it in GitHub Desktop.
See which images were resized. Great for CMS sites where the client uses a full resolution image.
window.onload = function() {
// All images on page as an array
var image = document.images;
// Loop trough each image and return its height/width values
for (var i = image.length - 1; i >= 0; i--) {
image[i].style.outline = "3px solid orange";
image[i].scrollIntoView();
alert("Image height: " + image[i].height + "px \n" + "Image width: " + image[i].width + "px \n" + "Original height: " + image[i].naturalHeight + "px \n" + "Original width: " + image[i].naturalWidth + "px \n");
image[i].style.outline = "0px none";
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment