Created
July 12, 2017 07:00
-
-
Save netsi1964/572f904e878226e5968e0003eb2a4444 to your computer and use it in GitHub Desktop.
Replaces any image on page with a Dummyimage.com image showing size
This file contains 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
var image = Array.from(document.querySelectorAll('img')); | |
image.map((ele,i) => { | |
var {width, height} = getComputedStyle(ele); | |
var newSrc = `http://dummyimage.com/${parseInt(width)}x${parseInt(height)}`; | |
if ('src' in ele) { | |
ele.setAttribute('src', newSrc) | |
} else { | |
var url = ele.style.backgroundImage; | |
console.log(url) | |
if (url) { | |
ele.style.backgroundImage = `url(${newSrc})` | |
} | |
} | |
ele.style.outline = 'solid blue' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment