UnfurledMediaItem
in package
implements
JsonSerializable
Represents an unfurled media item, which is the base for V2 components.
It allows you to specify an arbitrary url or attachment reference.
Tags
Table of Contents
Interfaces
- JsonSerializable
Constants
- LOADING_STATE_LOADED_NOT_FOUND = 3
- LOADING_STATE_LOADED_SUCCESS = 2
- LOADING_STATE_LOADING = 1
- LOADING_STATE_UNKNOWN = 0
- Loading states for unfurled media items.
Properties
- $content_type : string|null
- The media item's media type.
- $height : int|null
- Height of media item.
- $loading_state : int|null
- Loading state of the media item.
- $proxy_url : string|null
- A proxied URL of the media item.
- $url : string
- Source URL of media item (only supports http(s) and attachments).
- $width : int|null
- Width of media item.
Methods
- fromAttachment() : self
- Creates a new unfurled media item from an attachment.
- getUrl() : string
- Returns the URL of the media item.
- isLoaded() : bool
- Returns whether the media item was successfully loaded.
- isLoading() : bool
- Returns whether the media item is still loading.
- isNotFound() : bool
- Returns whether the media item failed to load.
- isResolved() : bool
- Returns whether the media item has been resolved.
- isUnknown() : bool
- Returns whether the media item's loading state is unknown.
- jsonSerialize() : array<string|int, mixed>
- {@inheritDoc}
- new() : self
- Creates a new unfurled media item.
- setResolvedData() : $this
- Sets the resolved data for the media item.
- setUrl() : $this
- Sets the URL of the media item.
Constants
LOADING_STATE_LOADED_NOT_FOUND
public
mixed
LOADING_STATE_LOADED_NOT_FOUND
= 3
LOADING_STATE_LOADED_SUCCESS
public
mixed
LOADING_STATE_LOADED_SUCCESS
= 2
LOADING_STATE_LOADING
public
mixed
LOADING_STATE_LOADING
= 1
LOADING_STATE_UNKNOWN
Loading states for unfurled media items.
public
mixed
LOADING_STATE_UNKNOWN
= 0
Properties
$content_type
The media item's media type.
private
string|null
$content_type
$height
Height of media item.
private
int|null
$height
$loading_state
Loading state of the media item.
private
int|null
$loading_state
$proxy_url
A proxied URL of the media item.
private
string|null
$proxy_url
$url
Source URL of media item (only supports http(s) and attachments).
private
string
$url
$width
Width of media item.
private
int|null
$width
Methods
fromAttachment()
Creates a new unfurled media item from an attachment.
public
static fromAttachment(Attachment|string $filename) : self
Parameters
- $filename : Attachment|string
-
Name of the attachment file, or null.
Return values
selfgetUrl()
Returns the URL of the media item.
public
getUrl() : string
Return values
stringisLoaded()
Returns whether the media item was successfully loaded.
public
isLoaded() : bool
Return values
boolisLoading()
Returns whether the media item is still loading.
public
isLoading() : bool
Return values
boolisNotFound()
Returns whether the media item failed to load.
public
isNotFound() : bool
Return values
boolisResolved()
Returns whether the media item has been resolved.
public
isResolved() : bool
Return values
boolisUnknown()
Returns whether the media item's loading state is unknown.
public
isUnknown() : bool
Return values
booljsonSerialize()
{@inheritDoc}
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>new()
Creates a new unfurled media item.
public
static new(string $url) : self
Parameters
- $url : string
-
URL or attachment reference of the media item.
Return values
selfsetResolvedData()
Sets the resolved data for the media item.
public
setResolvedData(array<string|int, mixed> $data) : $this
This is typically set by Discord after the media is resolved.
Parameters
- $data : array<string|int, mixed>
-
Resolved data from Discord.
Return values
$thissetUrl()
Sets the URL of the media item.
public
setUrl(string $url) : $this
Parameters
- $url : string
-
URL or attachment reference of the media item.