Kasador
Kasador

Reputation: 429

How to use instafeed.js to grab videos instead of only photos

I'm currently trying to grab videos only through a user's Instagram's account, however; I'm having some trouble and I'm currently using Instafeed.js to pull the data from instgram. How can I only pull videos? Would I need to use video.js and make my own video player?

Here's my code that ONLY pulls thumbnails from the videos.

 let userFeed = new Instafeed({
     get: 'user',
     userId: 'USER_ID',
     limit: 12,
     resolution: 'standard_resolution',
     clientId: 'CLIENT_ID',
     accessToken: 'ACCESS_TOKEN',
     sortBy: 'most-recent',
     template: '<div class="tile"><div class="text">{{model.user.full_name}}</div><img class="item" src="{{image}}"></div>',
     filter: function (image) {
         return image.type === 'video';
     }
 });
 userFeed.run();

Thanks to all who spend time helping me out!

Upvotes: 1

Views: 831

Answers (1)

Pal Singh
Pal Singh

Reputation: 1974

You can modify your filter method as follows and remove template property:

filter: function (image) {
    if (image.type === 'video') {
        image.template = '<video width="100%" controls loop><source src="' + image.videos.standard_resolution.url + '" type="video/mp4"/></video>';
        return true;
    }
    return false;
}

Upvotes: 1

Related Questions