Attachment

Represents a file or media attachment that can be added to a status.

Example

{
  "id": "22345792",
  "type": "image",
  "url": "https://files.mastodon.social/media_attachments/files/022/345/792/original/57859aede991da25.jpeg",
  "preview_url": "https://files.mastodon.social/media_attachments/files/022/345/792/small/57859aede991da25.jpeg",
  "remote_url": null,
  "text_url": "https://mastodon.social/media/2N4uvkuUtPVrkZGysms",
  "meta": {
    "original": {
      "width": 640,
      "height": 480,
      "size": "640x480",
      "aspect": 1.3333333333333333
    },
    "small": {
      "width": 461,
      "height": 346,
      "size": "461x346",
      "aspect": 1.3323699421965318
    },
    "focus": {
      "x": -0.27,
      "y": 0.51
    }
  },
  "description": "test media description",
  "blurhash": "UFBWY:8_0Jxv4mx]t8t64.%M-:IUWGWAt6M}"
}

Required attributes

id

Description: The ID of the attachment in the database. Type: String (cast from an integer but not guaranteed to be a number) Version history: Added in 0.6.0.

type

Description: The type of the attachment. Type: String (Enumerable, oneOf) - unknown = unsupported or unrecognized file type - image = Static image - gifv = Looping, soundless animation - video = Video clip - audio = Audio track Version history: Added in 0.6.0. Audio added in 2.9.1.

url

Description: The location of the original full-size attachment. Type: String (URL) Version history: Added in 0.6.0.

preview_url

Description: The location of a scaled-down preview of the attachment. Type: String (URL) Version history: Added in 0.6.0.

Optional attributes

remote_url

Description: The location of the full-size original attachment on the remote website. Type: String (URL), or null if the attachment is local Version history: Added in 0.6.0.

text_url

Description: A shorter URL for the attachment. Type: String (URL) Version history: Added in 0.6.0.

meta

Description: Metadata returned by Paperclip. Type: Hash Version history: Added in 1.5.0. meta[focus] added in 2.3.0.

May contain subtrees small and original, as well as various other top-level properties.

More importantly, there may be another top-level focus Hash object as of 2.3.0, with coordinates can be used for smart thumbnail cropping -- see Focal points for more.

description

Description: Alternate text that describes what is in the media attachment, to be used for the visually impaired or when media attachments do not load. Type: String Version history: Added in 2.0.0

blurhash

Description: A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet. Type: String Version history: Added in 2.8.1

See also

  • Status#media_attachments

  • /api/v1/media

Statusmedia
app/serializers/rest/media_attachment_serializer.rb

Last updated

Was this helpful?