AMP

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로 이동하기