MediaGalleryItem
in package
implements
JsonSerializable
Represents an item in a media gallery component.
Tags
Table of Contents
Interfaces
- JsonSerializable
Properties
- $description : string|null
- Description for the gallery item.
- $media : UnfurledMediaItem
- Media item for the gallery.
- $spoiler : bool
- Whether the gallery item is a spoiler.
Methods
- fromAttachment() : self
- Creates a new media gallery item from an attachment.
- getDescription() : string|null
- Returns the description for the media item.
- getMedia() : UnfurledMediaItem
- Returns the media item.
- isSpoiler() : bool
- Returns whether the media item is a spoiler.
- jsonSerialize() : array<string|int, mixed>
- {@inheritDoc}
- new() : self
- Creates a new media gallery item.
- setDescription() : $this
- Sets the description for the media item.
- setMedia() : $this
- Sets the media item.
- setSpoiler() : $this
- Sets whether the media item is a spoiler.
Properties
$description
Description for the gallery item.
private
string|null
$description
$media
Media item for the gallery.
private
UnfurledMediaItem
$media
$spoiler
Whether the gallery item is a spoiler.
private
bool
$spoiler
= false
Methods
fromAttachment()
Creates a new media gallery item from an attachment.
public
static fromAttachment(string $filename[, string|null $description = null ][, bool $spoiler = false ]) : self
Parameters
- $filename : string
-
Name of the attachment file.
- $description : string|null = null
-
Description for the media item (max 1024 characters).
- $spoiler : bool = false
-
Whether the media item is a spoiler.
Tags
Return values
selfgetDescription()
Returns the description for the media item.
public
getDescription() : string|null
Return values
string|nullgetMedia()
Returns the media item.
public
getMedia() : UnfurledMediaItem
Return values
UnfurledMediaItemisSpoiler()
Returns whether the media item is a spoiler.
public
isSpoiler() : bool
Return values
booljsonSerialize()
{@inheritDoc}
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>new()
Creates a new media gallery item.
public
static new(UnfurledMediaItem|string $media[, string|null $description = null ][, bool $spoiler = false ]) : self
Parameters
- $media : UnfurledMediaItem|string
-
Media item or URL of the media item.
- $description : string|null = null
-
Description for the media item (max 1024 characters).
- $spoiler : bool = false
-
Whether the media item is a spoiler.
Tags
Return values
selfsetDescription()
Sets the description for the media item.
public
setDescription(string|null $description) : $this
Parameters
- $description : string|null
-
Description for the media item (max 1024 characters).
Tags
Return values
$thissetMedia()
Sets the media item.
public
setMedia(UnfurledMediaItem|string $media) : $this
Parameters
- $media : UnfurledMediaItem|string
-
Media item or URL of the media item.
Return values
$thissetSpoiler()
Sets whether the media item is a spoiler.
public
setSpoiler([bool $spoiler = true ]) : $this
Parameters
- $spoiler : bool = true
-
Whether the media item is a spoiler.