Skip to content

Instantly share code, notes, and snippets.

@noboomu
Created April 2, 2015 15:50
Show Gist options
  • Save noboomu/2826603f59aab265812e to your computer and use it in GitHub Desktop.
Save noboomu/2826603f59aab265812e to your computer and use it in GitHub Desktop.
Update dom with natural width and height of images.
[].forEach.call(document.querySelectorAll('img'),function(i)
{
i.setAttribute('data-natural-width',i.naturalWidth);
i.setAttribute('data-natural-height',i.naturalHeight);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment