我正在使用 instafeed js 从 instagram 调用照片。有没有办法将每 4 个图像包装在一个 div 中?这甚至可能吗?这是我的代码:
jQuery(window).load(function(){
var userFeed = new Instafeed({
get: 'user',
userId: 1509441625,
accessToken: '1509441625.5b9e1e6.c20b3eb91b15404ab30084283ab3a9c9',
limit : 4,
resolution:'standard_resolution',
template: '<a target="_Blank" href="{{link}}"><img src="{{image}}" /></a> ',
});
userFeed.run();
});
我联系了 instafeed 的开发人员,他给了我一段未经测试的代码,我正在尝试调试:
var count = 0;
var userFeed = new Instafeed({
get: 'user',
userId: 1509441625,
accessToken: '1509441625.5b9e1e6.c20b3eb91b15404ab30084283ab3a9c9',
limit : 4,
resolution:'standard_resolution',
filter: function(image) {
count += 1;
if (count % 4 === 0) {
image.customTagOpen = '<div>';
image.customTagClose = '</div>';
} else {
image.customTagOpen = '';
image.customTagClose = '';
}
return true;
},
template: '{{model.customTagOpen}}<a target="_Blank" href="{{link}}"><img src="{{image}} /></a>{{model.customTagClose}}';
});
userFeed.run();
});
但我收到一个错误:在列出属性后缺少“}”。有什么建议吗?