AMP

amp-instagram

 
您现在可以使用此组件,在有效的 AMP 文档之外,使用此组件的 Bento 版本。 在 Bento 指南 中了解更多信息。

描述

显示 Instagram 嵌入。

 

必需的脚本

<script async custom-element="amp-instagram" src="https://cdn.ampproject.org/v0/amp-instagram-0.1.js"></script>

行为

widthheight 属性对于 Instagram 嵌入是特殊的。这些应该是 Instagram 图像的实际宽度和高度。系统会自动为 Instagram 在图像周围添加的“边框”添加空间。

许多 Instagram 图片是正方形的。当您设置 layout="responsive" 时,任何 widthheight 相同的值都可以使用。

示例

<amp-instagram
  data-shortcode="fBwFP"
  data-captioned
  width="400"
  height="400"
  layout="responsive"
>
</amp-instagram>

如果 Instagram 不是正方形,您需要输入图像的实际尺寸。

当使用非响应式布局时,您需要考虑为图像周围的“Instagram 边框”添加的额外空间。目前,图像的上方和下方各为 48px,两侧为 8px。

属性

data-shortcode Instagram 数据短代码在每个 Instagram 照片 URL 中都能找到。
例如,在 https://instagram.com/p/fBwFP 中,fBwFP 是数据短代码。
data-captioned 包括 Instagram 字幕。amp-instagram 将尝试调整大小到包含字幕的正确高度。
通用属性 此元素包括扩展到 AMP 组件的 通用属性

验证

请参阅 AMP 验证器规范中的 amp-instagram 规则

需要更多帮助吗?

您已阅读此文档多次,但它并没有真正涵盖您所有的问题? 也许其他人也有同样的感觉:请在 Stack Overflow 上联系他们。

转到 Stack Overflow
发现错误或缺少功能?

AMP 项目强烈鼓励您的参与和贡献! 我们希望您能成为我们开源社区的长期参与者,但我们也欢迎您对您特别感兴趣的问题做出一次性贡献。

转到 GitHub