Instafeed is a simple javascript plugin that enables you to add Instagram photos to your website.
You’ll need to register your website as an application with Instagram and get an Access Token before you start - Instagram has recently changed the process, but it is quite straight-forward, just follow the steps here.
Once you have created the app, navigate to Settings > Basic, scroll to the bottom of page, and click Add Platform.
Choose Website from the menu, add your website’s URL. I used a Codepen URL (https://codepen.io/matthewelsom/pen/YzGXxEP) for testing, you can change the platform or URL later.
Enter the name of the Facebook app you just created.
Enter your website’s URL.
In this example: https://codepen.io/matthewelsom/pen/YzGXxEP
Facebook may append a trailing forward slash when you save this form, please check this afetr saving.
Enter your website’s URL again.
Enter your website’s URL again.
Skip this section, we will not be switching the app to Live mode.
Save your changes, then click the Add or Remove Instagram Testers button.
This will allow your Instagram account to be accessed by your app while it is in Development Mode.
{app-id}
variable with your Instagram app ID - not the Facebook one!{redirect-uri}
must be exactly the same as the URL entered in the Client OAuth Settings.(IMAGE HERE)
https://api.instagram.com/oauth/authorize
?client_id={app-id}
&redirect_uri={redirect-uri}
&scope=user_profile,user_media
&response_type=code
Here is what my URL looks like…
https://api.instagram.com/oauth/authorize
?client_id=776301186285004
&redirect_uri=https://codepen.io/matthewelsom/pen/YzGXxEP
&scope=user_profile,user_media
&response_type=code
#_
.#_
for use in the next step.For example:
https://codepen.io/matthewelsom/pen/YzGXxEP?code=AQDa4f...#_
IGQVJYT2RubmVUT19rcHU0dnlXWlJ4Rk01R2Ric19oVlhPMTIxVW5MbW1LZAnJFZAkFHV1J1QlY5UUpHU0JkMVZAlVDQ3T1NVZAFBlaklPR1VTX1QxaGRLZAFVyTGxlVXVlQ2dmYkVacUx2SjZACQUwzUjJjZAgZDZD
I wanted to create an Instagram Feed on my About page - the feed would pull the latest Images with respective URLs from my IG account, I also wanted to show the Like count and Comment count to go with each image.
I decided to use a jekyll include
to templatize the feed; that basically means the feed code is seperated form my page code making it easier to update or relocate at a later date.
The include used on my About page:
<div id="instafeed"></div>
, the plugin will automatially look for this element and fill it with your thumbnails.instafeed.html
file:standard_rsolution
is the largest size at 612x612px.The template function allows you to customise the output for each image. A full list of template options are available here.
For my template I wrapped each image inside an <a>
tag that linked to the original photo (in a blank window), and included the Like and Comment scores for each photo.
If you are building your site in Jekyll make sure you wrap your template with the {% raw %}
and {% endraw %}
tags - this prevents the liquid language from being interupted by Jekyll.
Here is a sample feed, it shows my last 4 Instgram posts
See the Pen Sample Instagram Feed with Instafeed.js by Matthew Elsom (@matthewelsom) on CodePen.
Need to show your user details? You can use the {{model.user}}
fuction to do that.
{{model.user.username}}
{{model.user.profile_picture}}
{{model.user.full_name}}
See the Pen Sample Instagram Feed with Instafeed.js with User Details by Matthew Elsom (@matthewelsom) on CodePen.