forked from syntagmatic's block: Image Gallery
Created
February 5, 2016 04:21
-
-
Save ac1714/75089c9bc6ca1f4764fc to your computer and use it in GitHub Desktop.
Image Gallery
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
| <script src="http://d3js.org/d3.v3.js"></script> | |
| <style> | |
| body { | |
| background: #000; | |
| margin: 2px; | |
| } | |
| img { | |
| border-radius: 4px; | |
| padding: 2px; | |
| } | |
| </style> | |
| <script> | |
| d3.json("http://www.reddit.com/r/earthporn.json?limit=80", function(error, imgs) { | |
| // filter out posts without a thumbnail | |
| var images = imgs.data.children.filter(function(d) { | |
| return d.data.thumbnail.slice(-3) == "jpg"; | |
| }); | |
| images.forEach(function(img) { | |
| d3.select("body") | |
| .append("a") | |
| .attr("href", img.data.url) | |
| .append("img") | |
| .attr({ | |
| height: 66, | |
| src: img.data.thumbnail | |
| }); | |
| }); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment