AMP

Thank you!

amp-iframely

Description

Displays Iframely.com-powered rich media embeds

 

Required Scripts

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

Embeds and displays Iframely.com-powered rich media embeds from over 1900 third-party publishers. Shows URL previews as summary card for any other URL.

<amp-iframely> embeds content through the third-party vendor Iframely.com. It should not be confused with <amp-iframe>, which embeds any URL directly.

Required Script <script async custom-element="amp-iframely" src="https://cdn.ampproject.org/v0/amp-iframely-0.1.js"></script>
Supported Layouts responsive, fixed-height

Overview

The amp-iframely connects you to Iframely cloud service. It provides responsive embeds codes and rich media support for over 1900 third party publishers. Plus summary cards as URL previews for the rest of the Internet.

You'd likely get amp-iframely code generated by from Iframely APIs. But you may also skip making API calls and use Iframely in AMP directly (we recommend responsive layout, with resizable flag in that case).

Please get your API key at iframely.com.

Example: Embed third party via content ID

<amp-iframely width="400" height="225"
    data-id="I8NNa1s"
    layout="responsive"
    data-img>
</amp-iframely>
在 Playground 中打开此代码段

Example: Summary card for any URL via API key

<amp-iframely height="140"
    data-url="https://iframely.com"
    data-key="30ef29b325c50219755786a371c281ad"
    layout="fixed-height"
    resizable>
</amp-iframely>
在 Playground 中打开此代码段

Feel free to try any URL with the API key from the above example. However, it is restricted for use on amp.dev only.

Attributes

Indentifying

There are two ways to identify rich media. Either with the help of Iframely-issued ID, or with a pair of media URL and your API key (MD5-hashed for security reasons):

data-id Iframely content ID, if available
data-url

Alternatively, if no content ID, identify rich media by its canonical URL.

data-key

If data-url is used, also add the MD5 hash of your Iframely API key as data-key attribute. Hash your key, the unencrypted value won't work here.

Placing

amp-iframely supports responsive and fixed-height layouts:

width and height Use both attributes for responsive media to define its aspect-ratio. Use only height for a fixed-height layout. If you don't have media sizes - use what works best as a placeholder, and add resizable as below.
resizable A flag to add event listener and adjust component's height automatically to fit and match the rich media content. This works with both responsive and fixed-height layouts.
data-img Empty attribute, indicating that rich media's thumbnail image should be used as a placeholder while the component and its content loads. No value please - Iframely will find the reqiured image address on its own.

Any other of Iframely's query-string API parameters can be passed as data- prefixed attribute. For example, align="left" API parameter becomes data-align="left" attribute. Custom provider-specific options can also be passed as data- attribute.

Validation

As a mininum, either data-id attribute or a pair of data-url and data-key are required to identify the third party rich media content and authenticate with Iframely.

需要更多帮助?

您已多次阅读本文档,但它仍未能涵盖您的所有问题?也许其他人也这么觉得:在 Stack Overflow 上与他们联系。

前往 Stack Overflow
发现错误或缺少功能?

AMP 项目强烈鼓励您参与并做出贡献!我们希望您能成为我们开放源代码社区的持续参与者,但我们也欢迎您对所热衷问题做出一次性贡献。

前往 GitHub