Created
May 14, 2013 16:54
-
-
Save ada-lovecraft/5577530 to your computer and use it in GitHub Desktop.
An excerpt from the actual code
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
//spin through each image object | |
json.data.forEach(function(image,index,array) { | |
//we don't want gifs | |
if (!image.link.match(/\.gif$/)) { | |
//get the image extension | |
var ext = image.link.match(/\.\w+$/); | |
//change the link to give us the (l)arge version so we don't kill ourselves on bandwidth | |
//also remove the http://i.imgur.com/ text from the link | |
var match = image.link.match(/http:\/\/i\.imgur\.com\//); | |
image.match = match; | |
//image.link = image.link.replace(/\.\w+$/,'l' + ext).replace(/http:\/\/i.imgur.com\//g,''); | |
json.data[index] = image; | |
app.io.broadcast('global:status', { message: subredditName + " -- Found: " + image.link}); | |
} else { | |
//remove the image from the document if it's a gif | |
json.data.splice(index,1); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment