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 外框」新增的額外空間。目前圖片上方和下方為 48 像素,兩側為 8 像素。

屬性

data-shortcode instagram data-shortcode 可以在每張 Instagram 照片網址中找到。
例如,在 https://instagram.com/p/fBwFP 中,fBwFP 是 data-shortcode。
data-captioned 包含 Instagram 標題。amp-instagram 將嘗試調整大小以符合正確的高度,包含標題。
通用屬性 此元素包含擴充至 AMP 元件的通用屬性

驗證

請參閱 AMP 驗證器規格中的 amp-instagram 規則

需要更多協助嗎?

您已經閱讀本文件數十次,但它仍然沒有真正涵蓋您的所有問題?也許其他人也有同感:在 Stack Overflow 上與他們交流。

前往 Stack Overflow
發現錯誤或缺少功能?

AMP 專案強烈鼓勵您的參與和貢獻!我們希望您能成為我們開放原始碼社群的長期參與者,但我們也歡迎您針對您特別感興趣的問題提供一次性的貢獻。

前往 GitHub