DiscordPHP Documentation

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
link
https://discord.com/developers/docs/interactions/message-components#unfurled-media-items
since
10.5.0

Table of Contents

Interfaces

JsonSerializable

Properties

$url  : string
Source URL of media item (only supports http(s) and attachments).

Methods

fromAttachment()  : self
Creates a new unfurled media item from an attachment.
getUrl()  : string|null
Returns the URL of the media item.
jsonSerialize()  : array<string|int, mixed>
new()  : self
Creates a new unfurled media item.
setUrl()  : $this
Sets the URL of the media item.

Properties

$url

Source URL of media item (only supports http(s) and attachments).

protected string $url

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
self

getUrl()

Returns the URL of the media item.

public getUrl() : string|null
Return values
string|null

jsonSerialize()

public jsonSerialize() : array<string|int, mixed>
Tags
inheritDoc
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
self

setUrl()

Sets the URL of the media item.

public setUrl(string $url) : $this
Parameters
$url : string

URL or attachment reference of the media item.

Return values
$this

        
On this page

Search results