amp-instagram
描述
显示 Instagram 嵌入。
必需脚本
<script async custom-element="amp-instagram" src="https://cdn.ampproject.org/v0/amp-instagram-1.0.js"></script>
<script async custom-element="amp-instagram" src="https://cdn.ampproject.org/v0/amp-instagram-1.0.js"></script> <link rel="stylesheet" href="https://cdn.ampproject.org/v0/amp-instagram-1.0.css">
行为
width
和 height
属性对于 Instagram 嵌入是特殊的。这些应该是 Instagram 图像的实际宽度和高度。系统会自动为 Instagram 在图像周围添加的“边框”添加空间。
许多 Instagram 都是方形的。当您设置 layout="responsive"
时,任何 width
和 height
相同的值都有效。
示例
<amp-instagram data-shortcode="fBwFP" data-captioned width="400" height="400" layout="responsive" > </amp-instagram>
如果 Instagram 不是正方形,您将需要输入图像的实际尺寸。
当使用非响应式布局时,您需要考虑为图像周围的“Instagram 边框”添加的额外空间。目前,图像上下方为 48 像素,两侧为 8 像素。
在有效 AMP 文档之外独立使用
Bento 允许您在非 AMP 页面中使用 AMP 组件,而无需承诺完全有效的 AMP。您可以将这些组件放置在使用不支持 AMP 的框架和 CMS 的实现中。请参阅我们的指南 在非 AMP 页面中使用 AMP 组件,了解更多信息。
要查找 amp-instagram
的独立版本,请参阅 bento-instagram
。
属性
data-shortcode | Instagram 数据短代码可在每个 Instagram 照片 URL 中找到。 例如,在 https://instagram.com/p/fBwFP 中, fBwFP 是数据短代码。 |
data-captioned | 包含 Instagram 说明。amp-instagram 将尝试调整大小以适应包括说明在内的正确高度。 |
通用属性 | 此元素包括 扩展到 AMP 组件的通用属性。 |
需要更多帮助?
您已经阅读此文档十几次了,但它并没有真正涵盖您的所有问题?也许其他人也有同感:请在 Stack Overflow 上与他们联系。
转到 Stack Overflow 发现错误或缺少功能?AMP 项目强烈鼓励您的参与和贡献!我们希望您成为我们开源社区的长期参与者,但我们也欢迎您为自己特别热衷的问题做出一次性贡献。
转到 GitHub