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 | amp-twitter.html 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 |
---|---|
The 'example1' tag is missing or incorrect, but required by 'example2'. | Error thrown when required amp-twitter extension .js script tag is missing or incorrect. |
The tag 'example1' is missing a mandatory attribute - pick one of example2. | Error thrown when neither data-tweetid or src is included. One of these attributes is mandatory. |
Missing URL for attribute 'example1' in tag 'example2'. | Error thrown when data-tweetid or src is missing it's URL. |
Malformed URL 'example3' for attribute 'example1' in tag 'example2'. | Error thrown when data-tweetid or src URL is invalid. |
Invalid URL protocol 'example3:' for attribute 'example1' in tag 'example2'. | Error thrown data-tweetid or src URL is http ; https protocol required. |
The implied layout 'example1' is not supported by tag 'example2'. | Error thrown when implied layout is set to CONTAINER ; this layout type isn't supported. |
The specified layout 'example1' is not supported by tag 'example2'. | Error thrown when specified layout is set to CONTAINER ; this layout type isn't supported. |
The property 'example1' in attribute 'example2' in tag 'example3' is set to 'example4', which is invalid. | 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.