Sort images by most recent and filter for images with likes > x

507 Views Asked by At

In instafeed.js, I have the ability to sortBy tagged pictures either by most-liked or most-recent. Those options are mutually exclusive. I am trying to find a middle ground to do both. I would like to sort by most-recent and then display those that have likes > x amount. How can I achieve this in instafeed.js?

var feed = new Instafeed({
  target: 'instafeed',
  get: 'tagged',
  tagName: 'dog',
  limit: '10',
  sortBy: 'most-recent',
  resolution: 'standard_resolution',
  clientId: 'xxxxx', 
  template:'<div class="tile"><div class="text"><b>{{likes}} &hearts; </b>{{model.user.full_name}}</div><img class="item" src="{{image}}"></div>',
  filter: function(image) {
    //filter for recent images with most like
  }
});
1

There are 1 best solutions below

0
On BEST ANSWER

According to this https://github.com/stevenschobert/instafeed.js/issues/21 the image parameter in the filter function has attribute likes. So you should be able to do something like

filter: function(image) {
  return image.likes.count >= minAmount;
}