Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
grove.io dotjs script for inlining images
setInterval(function(){
$('.content a').each(function() {
if (/\.(gif|jpe?g|png)/i.test($(this).text()))
$(this).html('<img src="'+$(this).text()+'"/>"')
})
}, 1000)
@mathiasbynens

This comment has been minimized.

Copy link

@mathiasbynens mathiasbynens commented Oct 14, 2011

Without jQuery:

(function() {
  var forEach = [].forEach;
  setInterval(function() {
    forEach.call(document.querySelectorAll('.content a'), function(el) {
      var src = el.innerText || el.textContent;
      if (/\.(gif|jpe?g|png)/i.test(src)) {
        el.innerHTML = '<img src="' + src + '">');
      }
    });
  }, 1000);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment