Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sorting renditions ratio
<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
You can’t perform that action at this time.