Skip to content

Instantly share code, notes, and snippets.

@whistlerbrad
Created February 26, 2018 03:01
Show Gist options
  • Select an option

  • Save whistlerbrad/82edd194928101adb79baecd2cd8b8f1 to your computer and use it in GitHub Desktop.

Select an option

Save whistlerbrad/82edd194928101adb79baecd2cd8b8f1 to your computer and use it in GitHub Desktop.
fix for IG token restrictions
theme.Instagram = (function() {
function Instagram(container) {
var $container = this.$container = $(container);
var id = $container.attr('data-section-id');
var instafeedEl = this.instagram = $('#Instafeed-' + id);
var instafeedId = this.instagram = 'Instafeed-' + id;
var apiSuccess = 0;
var imageLimit = instafeedEl.attr('data-count');
var userFeed = new Instafeed({
get: 'user',
userId: 'self',
target: instafeedId,
accessToken: instafeedEl.attr('data-access-token'),
sortBy: 'most-recent',
resolution: 'standard_resolution',
template: '{% raw %}<a href="{{link}}" target="_blank" style="background-image: url({{image}});" class="grid__item instagram--square '+instafeedEl.attr('data-grid')+'"><span class="icon icon-instagram"></span></a>{% endraw %}',
limit: 24,
filter: function(image) {
if (image.id && apiSuccess < imageLimit) {
apiSuccess = apiSuccess + 1;
return true;
}
return false;
}
});
if( !_.isUndefined( userFeed.options.accessToken) ){
userFeed.run();
}
}
Instagram.prototype = _.assignIn({}, Instagram.prototype, {});
return Instagram;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment