使用过滤器限制-instafeed.js [英] Limit with filter - instafeed.js
问题描述
我正在使用instafeed.js
的强大工具与instagram的api进行交互.我目前正在尝试将结果过滤为仅image.type === 'video'
.我已经能够使它工作.唯一的问题是它从不满足limit:10
设置.不知何故,它可能会拉动所有类型(image
和video
),然后应用过滤器.仅对视频应用过滤器时,是否有可能满足10
的限制?
I am using the great tool of instafeed.js
to interact with instagram’s api. I am currently trying to filter results to only be image.type === 'video'
. I have been able to get that to work. The only problem is that it never satisfies the limit:10
set. Somehow it may be pulling all types(image
and video
) and then applying the filter. Is it possible to meet the limit 10
while applying a filter for videos only?
var feed = new Instafeed({
limit: '10',
sortBy: 'most-liked',
resolution: 'standard_resolution',
clientId: 'xxxxx',
template:'<div class="tile"><div class="text"><b>{{likes}} ♥ </b>{{model.user.full_name}}</div><img class="item" src="{{image}}"></div>',
filter: function(image) {
return image.type === 'video';
}
});
推荐答案
您是正确的,在filter
.
要解决此问题,请尝试将limit
设置为更高的数字,然后在出现以下情况后删除其他图像:
To get around that, try setting the limit
to a higher number, then removing extra images after the fact:
var feed = new Instafeed({
limit: 30,
sortBy: 'most-liked',
resolution: 'standard_resolution',
clientId: 'xxxxx',
template:'<div class="tile"><div class="text"><b>{{likes}} ♥ </b>{{model.user.full_name}}</div><img class="item" src="{{image}}"></div>',
filter: function(image) {
return image.type === 'video';
},
after: function () {
var images = $("#instafeed").find('div');
if (images.length > 10) {
$(images.slice(10, images.length)).remove();
}
}
});
您还可以在Github上查看此线程 ,以获取更多详细信息.
You can also check this thread on Github for more details.
这篇关于使用过滤器限制-instafeed.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!