Skip to content

Instantly share code, notes, and snippets.

@vadimdemedes
Created March 21, 2013 17:58
Show Gist options
  • Save vadimdemedes/5215164 to your computer and use it in GitHub Desktop.
Save vadimdemedes/5215164 to your computer and use it in GitHub Desktop.
var assets = new Chute.API.Assets({ album: 'ALBUM_SHORTCUT '}).toData();
assets.on('data:load', function(){
var items = assets.data.items();
var popularAssets = _.filter(items, function(item){
return item.hearts > 10;
});
var filteredAssets = [];
async.forEach(popularAssets, function(asset, nextAsset){
var image = new Image;
image.onload = function(){
filteredAssets.push(asset);
nextAsset();
};
image.onerror = function(){ nextAsset(); };
image.src = asset.url;
}, function(){
// Ready to use data, filtered data set is in filteredAssets variable
});
});
assets.load();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment