javascriptjqueryhtmlpluginsinstafeedjs

Instafeed js add wrapper around every 4 image


I am using instafeed js to call photos from instagram. Is there a way to wrap every 4 images inside a div? is this even possible? Here is my code:

  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();

    });

I reached out to the developer of instafeed and he gave me a untested chunck of code that im trying to debug:

      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();

    });

But I get a error : missing "}" after property listing. any advice?


Solution

  • There is an incorrectly placed semicolon at the end of the template option line.

    Try changing that semicolon ; to a comma ,

    template: '{{model.customTagOpen}}<a target="_Blank" href="{{link}}"><img src="{{image}} /></a>{{model.customTagClose}}',