Lukas
Lukas

Reputation: 10340

Embedding Instagram via JavaScript

We are using Instagram's oEmbed-API to get embed codes. However, we do not want to solely rely on that API and generate embed codes ourselves. The embed code as provided by the API (or the website) includes a lot of html, css image data and text content, all of that already has to be there before you can work the embed js on it. This is a problem because we cannot implement a generic embed code but have to know the instagram content for each photo or video in advance.

My question is: Ist there a generic embed code, something like this, for instagram?

<script async defer=\"defer\" src=\"//platform.instagram.com/en_US/embeds.js\"></script>
<script>instgrm.Embeds.genenerate('some instragram ID for instance')<script/>

Upvotes: 6

Views: 19807

Answers (1)

krisrak
krisrak

Reputation: 12952

You can use iframe to embed like this:

<iframe src="https://www.instagram.com/p/BFKjVxkBsCC/embed" width="400" height="480" frameborder="0" scrolling="no" allowtransparency="true"></iframe>

adding /embed to instagram post URL will give you image that can be embedded

adding /embed/captioned will add caption to the image

Here is link to easily generate embed code: https://www.picodash.com/instagram/embed#https://www.instagram.com/p/BFKjVxkBsCC/

Upvotes: 12

Related Questions