Skip to content

Instantly share code, notes, and snippets.

@riccardomares
Last active October 6, 2021 09:08
Show Gist options
  • Save riccardomares/4dd5aeaac9af3af6f8f61ecc0348c668 to your computer and use it in GitHub Desktop.
Save riccardomares/4dd5aeaac9af3af6f8f61ecc0348c668 to your computer and use it in GitHub Desktop.
/*
Find IMG tags without width or height definitions
@note: please use https://mrcoles.com/bookmarklet/ to create your own bookmarklet
*/
function getImageWithoutDimensions(){
console.group("getImageWithoutDimensions");
n = 0;
imArray = [];
is = document.getElementsByTagName("img");
for (i=0;i<is.length;i++){
if (is[i].getAttribute("width") == null || is[i].getAttribute("height") == null){
console.log(is[i]);
imArray.push(is[i]);
n++;
}
}
console.groupEnd();
alert("You have " + n + " img tag without width or height");
return imArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment