Skip to content

Templating

Ben edited this page Apr 14, 2020 · 3 revisions

Using custom templates with Instafeed

Instafeed uses mustache-style templates to produce HTML for your page. If you want to change the HTML Instafeed creates, you can provide your own template.

The default template is:

<a href="{{link}}"><img title="{{caption}}" src="{{image}}" /></a>

This produces a link pointing to the post on Instagram, containing the image, with the title set to the caption.

You can use the following templating tags:

  • {{image}} The URL to the image (The first image of an album post, or the preview frame of a video)
  • {{type}} One of either image, video, and album
  • {{link}} The URL of the post on Instagram

Accessing the Instagram API response

The raw data object returned by Instagram, plus any attributes you add using the transform function are accessible via the model tag. eg: {{model.id}} returns the post's ID.

The fields currently available are:

  • caption: The Media's caption text. Not returnable for Media in albums.
  • id: The Media's ID.
  • media_type: The Media's type. Can be IMAGE, VIDEO, or CAROUSEL_ALBUM.
  • media_url: The Media's URL.
  • permalink: The Media's permanent URL.
  • thumbnail_url: The Media's thumbnail image URL. Only available on VIDEO Media.
  • timestamp: The Media's publish date in ISO 8601 format.
  • username: The Media owner's username.
Clone this wiki locally