2020-01-01 22:37:59 +01:00
|
|
|
|
---
|
|
|
|
|
title: Card
|
2020-01-12 14:11:56 +01:00
|
|
|
|
description: Represents a rich preview card that is generated using OpenGraph tags from a URL.
|
2020-01-01 22:37:59 +01:00
|
|
|
|
menu:
|
|
|
|
|
docs:
|
|
|
|
|
parent: entities
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
{{< tabs >}}
|
|
|
|
|
{{< tab title="video" >}}
|
|
|
|
|
```javascript
|
|
|
|
|
{
|
|
|
|
|
"url": "https://www.youtube.com/watch?v=OMv_EPMED8Y",
|
|
|
|
|
"title": "♪ Brand New Friend (Christmas Song!)",
|
|
|
|
|
"description": "",
|
|
|
|
|
"type": "video",
|
|
|
|
|
"author_name": "YOGSCAST Lewis & Simon",
|
|
|
|
|
"author_url": "https://www.youtube.com/user/BlueXephos",
|
|
|
|
|
"provider_name": "YouTube",
|
|
|
|
|
"provider_url": "https://www.youtube.com/",
|
|
|
|
|
"html": "<iframe width=\"480\" height=\"270\" src=\"https://www.youtube.com/embed/OMv_EPMED8Y?feature=oembed\" frameborder=\"0\" allowfullscreen=\"\"></iframe>",
|
|
|
|
|
"width": 480,
|
|
|
|
|
"height": 270,
|
|
|
|
|
"image": "https://files.mastodon.social/preview_cards/images/014/179/145/original/9cf4b7cf5567b569.jpeg",
|
|
|
|
|
"embed_url": ""
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
{{< endtab >}}
|
|
|
|
|
|
|
|
|
|
{{< tab title="photo" >}}
|
|
|
|
|
```javascript
|
|
|
|
|
{
|
|
|
|
|
"url": "https://www.flickr.com/photos/tomfenskephotography/49088768431/",
|
|
|
|
|
"title": "Oregon",
|
|
|
|
|
"description": "",
|
|
|
|
|
"type": "photo",
|
|
|
|
|
"author_name": "Tom Fenske Photography",
|
|
|
|
|
"author_url": "https://www.flickr.com/photos/tomfenskephotography/",
|
|
|
|
|
"provider_name": "Flickr",
|
|
|
|
|
"provider_url": "https://www.flickr.com/",
|
|
|
|
|
"html": "",
|
|
|
|
|
"width": 1024,
|
|
|
|
|
"height": 427,
|
|
|
|
|
"image": "https://files.mastodon.social/preview_cards/images/014/287/139/original/651b1c6976817824.jpeg",
|
|
|
|
|
"embed_url": "https://live.staticflickr.com/65535/49088768431_6a4322b3bb_b.jpg"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
{{< endtab >}}
|
|
|
|
|
|
|
|
|
|
{{< tab title="link" >}}
|
|
|
|
|
```javascript
|
|
|
|
|
{
|
|
|
|
|
"url": "https://www.theguardian.com/money/2019/dec/07/i-lost-my-193000-inheritance-with-one-wrong-digit-on-my-sort-code",
|
|
|
|
|
"title": "‘I lost my £193,000 inheritance – with one wrong digit on my sort code’",
|
|
|
|
|
"description": "When Peter Teich’s money went to another Barclays customer, the bank offered £25 as a token gesture",
|
|
|
|
|
"type": "link",
|
|
|
|
|
"author_name": "",
|
|
|
|
|
"author_url": "",
|
|
|
|
|
"provider_name": "",
|
|
|
|
|
"provider_url": "",
|
|
|
|
|
"html": "",
|
|
|
|
|
"width": 0,
|
|
|
|
|
"height": 0,
|
|
|
|
|
"image": null,
|
|
|
|
|
"embed_url": ""
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
{{< endtab >}}
|
|
|
|
|
{{< endtabs >}}
|
|
|
|
|
|
|
|
|
|
## Required attributes
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `url` {#url}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** Location of linked resource.\
|
|
|
|
|
**Type:** String \(URL\)\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.0.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `title` {#title}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** Title of linked resource.\
|
|
|
|
|
**Type:** String\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.0.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `description` {#description}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** Description of preview.\
|
|
|
|
|
**Type:** String\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.0.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `type` {#type}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** The type of the preview card.\
|
|
|
|
|
**Type:** String \(Enumerable, oneOf\)\
|
|
|
|
|
`link` = Link OEmbed\
|
|
|
|
|
`photo` = Photo OEmbed\
|
|
|
|
|
`video` = Video OEmbed\
|
|
|
|
|
`rich` = iframe OEmbed. Not currently accepted, so won't show up in practice.\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.3.0
|
|
|
|
|
|
|
|
|
|
## Optional attributes
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `author_name` {#author_name}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** The author of the original resource.\
|
|
|
|
|
**Type:** String\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.3.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `author_url` {#author_url}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** A link to the author of the original resource.\
|
|
|
|
|
**Type:** String \(URL\)\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.3.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `provider_name` {#provider_name}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** The provider of the original resource.\
|
|
|
|
|
**Type:** String\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.3.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `provider_url` {#provider_url}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** A link to the provider of the original resource.\
|
|
|
|
|
**Type:** String \(URL\)\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.3.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `html` {#html}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** HTML to be used for generating the preview card.\
|
|
|
|
|
**Type:** String \(HTML\)\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.3.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `width` {#width}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** Width of preview, in pixels.\
|
|
|
|
|
**Type:** Number\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.3.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `height` {#height}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** Height of preview, in pixels.\
|
|
|
|
|
**Type:** Number\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.3.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `image` {#image}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** Preview thumbnail.\
|
|
|
|
|
**Type:** String \(URL\)\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 1.0.0
|
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
### `embed_url` {#embed_url}
|
2020-01-01 22:37:59 +01:00
|
|
|
|
|
2020-01-12 14:11:56 +01:00
|
|
|
|
**Description:** Used for photo embeds, instead of custom `html`.\
|
|
|
|
|
**Type:** String \(URL\)\
|
2020-01-01 22:37:59 +01:00
|
|
|
|
**Version history:** Added in 2.1.0
|
|
|
|
|
|
|
|
|
|
## See also
|
|
|
|
|
|
|
|
|
|
{{< page-ref page="status.md" >}}
|
|
|
|
|
|
|
|
|
|
{{< caption-link url="https://github.com/tootsuite/mastodon/blob/master/app/serializers/rest/preview_card_serializer.rb" caption="app/serializers/rest/preview\_card\_serializer.rb" >}}
|
|
|
|
|
|