- Paste this into your browser console.
- Start resizing the window.
- Any images that are ever displayed in a blurry fashion will throw an error and get faded out to 0.05 opacity.
Created
April 11, 2019 17:29
-
-
Save markjaquith/55aedbe2bec178099e36eb161d8e01e7 to your computer and use it in GitHub Desktop.
Identify images that are displayed wider than their natural width (which results in them looking blurry)
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
window.addEventListener('resize', () => { | |
Array.from(document.querySelectorAll('img')).forEach(img => { | |
if ((img.clientWidth * window.devicePixelRatio) > img.naturalWidth) { | |
console.error(img); | |
img.style.opacity = '0.05'; | |
} else { | |
img.style.opacity = '1'; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment