Last active
December 22, 2015 06:58
-
-
Save kamilogorek/6434504 to your computer and use it in GitHub Desktop.
Sorting renditions ratio
This file contains 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
<script type="text/javascript"> | |
var fapiResponse = {{ albums[0].photos[0].images | json_encode | raw }}; | |
var renditions = []; | |
var ratios = {}; | |
for (key in fapiResponse) { | |
renditions.push(key.split('_retina')[0]); | |
} | |
renditions.map(function(rendition, i) { | |
var dimensions = rendition.split('x'); | |
var ratio = Math.round(parseInt(dimensions[0], 10) / parseInt(dimensions[1], 10) * 1000) / 1000; | |
ratios[ratio] = { | |
ratio: ratio, | |
rendition: rendition | |
} | |
}); | |
console.dir(ratios); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment