Created
September 18, 2017 11:03
-
-
Save udovichenko/bb7d0a54b8d4274535174733d322d4ce to your computer and use it in GitHub Desktop.
Get Image Ratio of background-image vanilla js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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