Media
in package
A picture or a file attached to a message.
url is deliberately nullable, and the difference matters. A Discord
attachment arrives with a CDN link anyone can open; a Telegram photo arrives
as a file id, and turning that into a URL means asking the Bot API — which
returns a link with the bot token in the path. So a connector that can
only offer such a link hands over null and keeps the token to itself, and
the relay falls back to uploading the bytes or naming the file.
Tags
Table of Contents
Constants
- FILE : mixed = 'file'
- Anything else: a document, an audio clip, a video.
- IMAGE : mixed = 'image'
- Renderable by the destination as an image rather than a link.
Properties
- $caption : string|null
- $id : string|null
- $kind : string
- $link : string|null
- $mimeType : string|null
- $name : string|null
- $size : int|null
- $url : string|null
Methods
- __construct() : mixed
- isImage() : bool
Constants
FILE
Anything else: a document, an audio clip, a video.
public
mixed
FILE
= 'file'
IMAGE
Renderable by the destination as an image rather than a link.
public
mixed
IMAGE
= 'image'
Properties
$caption read-only
public
string|null
$caption
= null
$id read-only
public
string|null
$id
= null
$kind read-only
public
string
$kind
= self::FILE
$link read-only
public
string|null
$link
= null
$mimeType read-only
public
string|null
$mimeType
= null
$name read-only
public
string|null
$name
= null
$size read-only
public
int|null
$size
= null
$url read-only
public
string|null
$url
= null
Methods
__construct()
public
__construct([string $kind = self::FILE ][, string|null $url = null ][, string|null $id = null ][, string|null $name = null ][, string|null $caption = null ][, int|null $size = null ][, string|null $link = null ][, string|null $mimeType = null ]) : mixed
Parameters
- $kind : string = self::FILE
-
One of IMAGE or FILE.
- $url : string|null = null
-
A link anyone may follow — never one carrying a credential.
- $id : string|null = null
-
The platform's own handle for it, for a connector that must re-fetch.
- $name : string|null = null
-
A filename to show.
- $caption : string|null = null
-
Text the platform attached to the file rather than to the message.
- $size : int|null = null
-
In bytes, when the platform says — what decides whether it is small enough to copy across rather than describe.
- $link : string|null = null
-
A public page showing it — a post on t.me — for when there is no
urlto the file itself. What a network that can only carry text is given instead of the file's name. - $mimeType : string|null = null
-
As the platform reported it, e.g.
image/gif— how a network that sends a GIF differently from a still photo tells the two apart.
isImage()
public
isImage() : bool