Skip to content

Instantly share code, notes, and snippets.

Created August 17, 2011 00:29
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save defunkt/1150519 to your computer and use it in GitHub Desktop. dotjs script for inlining images
$('.content a').each(function() {
if (/\.(gif|jpe?g|png)/i.test($(this).text()))
$(this).html('<img src="'+$(this).text()+'"/>"')
}, 1000)
Copy link

Without jQuery:

(function() {
  var forEach = [].forEach;
  setInterval(function() {'.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