Skip to content

Instantly share code, notes, and snippets.

@udovichenko
Created September 18, 2017 11:03
Show Gist options
  • Save udovichenko/bb7d0a54b8d4274535174733d322d4ce to your computer and use it in GitHub Desktop.
Save udovichenko/bb7d0a54b8d4274535174733d322d4ce to your computer and use it in GitHub Desktop.
Get Image Ratio of background-image vanilla js
i=document.querySelector('.mfp-content .image');
bg=getComputedStyle(i)['background-image'];
u=bg.split('"')[1];
i=new Image();
i.src=u;
i.naturalWidth/i.naturalHeight;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment