What is the most efficient way to embed multiple Instagram photos?

4.6k views Asked by At

I am trying to embed around 20 Instagram photos on my website. The photos are different for each page, and I receive all the Instagram urls in a php array in this format

https://instagram.com/p/xxxxxxxxxx/media/?size=m

I am currently just using a foreach loop and embedding them like this

<img src="https://instagram.com/p/xxxxxxxxxx/media/?size=m">
<img src="https://instagram.com/p/xxxxxxxxxy/media/?size=m">
<img src="https://instagram.com/p/xxxxxxxxxz/media/?size=m">

I was thinking that this isn't the most efficient method due to the fact that each image src has to redirect to the actual source.

The only other method I found was this url

https://api.instagram.com/oembed/?url=https://instagram.com/p/xxxxxxxxxx/media/?size=m

But using this method would mean I need to json decode for every image to find its actual source.


Is there some way I could convert the https://instagram.com/p/xxxxxxxxxx/media/?size=m URL to a direct image url without dozens of server calls?

1

There are 1 answers

0
Niraj Shakya On

Instagram API only provide single post or photo to embed in your website. You need to use third party tools to embed multiple Instagram photos. There are lots of third party tools but I highly recommend to use SnapWidget .