Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created August 17, 2011 00:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save defunkt/1150519 to your computer and use it in GitHub Desktop.
Save defunkt/1150519 to your computer and use it in GitHub Desktop.
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
Copy link

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