Skip to content

Instantly share code, notes, and snippets.

@ada-lovecraft
Created May 14, 2013 16:54
Show Gist options
  • Save ada-lovecraft/5577530 to your computer and use it in GitHub Desktop.
Save ada-lovecraft/5577530 to your computer and use it in GitHub Desktop.
An excerpt from the actual code
//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