Description | Displays a Twitter Tweet. |
Availability | Stable |
Required Script | <script async custom-element="amp-twitter" src="https://cdn.ampproject.org/v0/amp-twitter-0.1.js"></script> |
Examples | twitter.amp.html |
The following lists validation errors specific to the amp-twitter
tag
(see also amp-twitter
in the AMP validator specification:
Validation Error | Description |
---|---|
TAG_REQUIRED_BY_MISSING | Error thrown when required amp-twitter extension .js script tag is missing or incorrect. |
MANDATORY_ONEOF_ATTR_MISSING | Error thrown when neither data-tweetid or src is included. One of these attributes is mandatory. |
MISSING_URL | Error thrown when data-tweetid or src is missing it's URL. |
INVALID_URL | Error thrown when data-tweetid or src URL is invalid. |
INVALID_URL_PROTOCOL | Error thrown data-tweetid or src URL is http ; https protocol required. |
IMPLIED_LAYOUT_INVALID | Error thrown when implied layout is set to CONTAINER ; this layout type isn't supported. |
SPECIFIED_LAYOUT_INVALID | Error thrown when specified layout is set to CONTAINER ; this layout type isn't supported. |
INVALID_PROPERTY_VALUE_IN_ATTR_VALUE | Error thrown when invalid value is given for attributes height or width . For example, height=auto triggers this error for all supported layout types, with the exception of NODISPLAY . |
CAVEAT
Twitter does not currently provide an API that yields fixed aspect ratio Tweet embeds. We currently automatically proportionally scale the Tweet to fit the provided size, but this may yield less than ideal appearance. Authors may need to manually tweak the provided width and height. You may also use the media
attribute to select the aspect ratio based on screen width. We are looking for feedback how feasible this approach is in practice.
Example:
<amp-twitter width=486 height=657
layout="responsive"
data-tweetid="585110598171631616"
data-cards="hidden">
</amp-twitter>
data-tweetid
The ID of the tweet. In a URL like https://twitter.com/joemccann/status/640300967154597888 640300967154597888
is the tweetID.
data-nameofoption
Options for the Tweet appearance can be set using data-
attributes. E.g. data-cards="hidden"
deactivates Twitter cards. For documentation of the available options, see Twitter's docs.