Skip to content

Social feeds ​

Feeds for Instagram and TikTok are provided by the SynSocial plugin, included with the common www.min.js file via {{ content_for_footer }}.

Options ​

OptionTypeDefaultRequiredDescription
elmHTMLElement—YesThe element to render the feed into
limitinteger12NoMaximum number of feed items to render
templatefunction(see below)NoFunction receiving a feed item and returning an HTML string
talent_idinteger—NoScope the feed to a specific talent record (deprecated)
agency_idintegerSyngency.agency_idNoDefaults to the current agency (deprecated)
handlestring—YesSocial handle to scope the feed

Usage ​

The default template renders a linked image, using a video thumbnail if the item is a video. Pass a custom template function to override the markup per item.

Example ​

Renders an agency feed on the page, with flexible JavaScript which supports agency or talent feeds:

liquid
{% for social in agency.social %}
  {% if social.service == 'instagram' and social.auth %}
    <div id="synsocialInstagram" class="synsocial-instagram pt-3" data-username="{{ social.profile_name }}" data-type="agency" data-id="{{ agency.id }}">
      <div class="row xs-gutters justify-content-center">
        <!-- Content of .row to be replaced when rendering feed with JS -->
        <div class="col text-center py-5">
          <i class="fal fa-spinner-third fa-spin fa-2x"></i>
        </div>
      </div>
    </div>
    {% break %}
  {% endif %}
{% endfor %}
js
// Instagram: SynSocial
if ( $('#synsocialInstagram').length ) {
  let $synSocialEl = $('#synsocialInstagram'),
      igUsername = $synSocialEl.data('username') || null,
      $synSocialFeedEl = $synSocialEl.find('.row').first()

  if ( igUsername ) {
    // Clear loader content
    $synSocialFeedEl.empty()
    // Render feed into node (not $el)
    SynSocial.instagram.renderFeed($synSocialFeedEl[0], {
      handle: igUsername,
      limit: 12,
      template: (item) => {
        if ( item.image ) {
          return `<div class="col-4 col-md-2"><div class="ig-item mb-gutter" data-caption="${item.image.caption}"><a href="${item.image.permalink}" target="_blank" class="ig-image" style="background-image:url(${SynSocial.baseUrl}/${item.key})" title="Open in Instagram"></a></div></div>`
        }
        else if ( item.video ) {
          return `<div class="col-4 col-md-2"><div class="ig-item mb-gutter" data-caption="${item.video.caption}"><a href="${item.video.permalink}" target="_blank" class="ig-video" style="background-image:url(${SynSocial.baseUrl}/${item.key})" title="Open in Instagram"></a></div></div>`
        }
      }
    })
  }
}

Events ​

Events are fired on the container element passed to SynSocial's renderFeed() method.

EventDescription
feedRendered.synSocialFired after the feed object is populated and the container innerHTML is updated. Passes an object with count (the number of feed.items) and items (array of the feed.items).

Example ​

Initialize a slider once the feed container is populated:

js
synSocialFeedEl.addEventListener('feedRendered.synSocial', e => {
  console.log('SynSocial: Feed rendered', e.detail.count, e.detail.items)
  initInstagramFeedSlider()
})