Last active
August 30, 2016 13:01
-
-
Save oflow/1ef73dd2fc789ea5ccd0e0c81a91b45f to your computer and use it in GitHub Desktop.
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
['ajax', 'data-src', 'data-lazy-src', 'data-original', 'rel:bf_image_src'].forEach((attr) => { | |
var elms = document.querySelectorAll('*[' + attr.replace(/:/, '\\:') + ']'); | |
for (var i = 0; i < elms.length; i++) { | |
if (elms[i].nodeName !== 'IMG') { | |
let img = document.createElement('img'); | |
img.src = elms[i].getAttribute(attr); | |
img.style.cssText = 'max-width: 100%; max-height: 100%;'; | |
elms[i].appendChild(img); | |
} else { | |
elms[i].src = elms[i].getAttribute(attr); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment