Developers

Video

A populated Video Picker field returns a Video object. You can also obtain one with craft.videoPicker.getVideoByUrl() or a source's getVideoById() method.

Properties

id

Type: string|null

The ID of the video.

url

Type: string|null

The URL of the video.

sourceHandle

Type: string|null

A handle identifying the video source, e.g. youtube or dailymotion.

date

Type: DateTime|null

The date the video was published or created (DateTime object).

duration

Type: int|null

Duration of the video in seconds.

duration8601

Type: string

Duration of the video in ISO8601 format.

plays

Type: int|null

The number of times the video has been played.

authorName

Type: string|null

The name of the video's author.

authorUrl

Type: string|null

URL to the author’s profile or channel.

authorUsername

Type: string|null

Username of the author.

thumbnails

Type: array

An array of thumbnail records. Each record contains a url and may include integer width and height values.

title

Type: string|null

The title of the video.

description

Type: string|null

The description of the video.

private

Type: bool

Whether the video is private.

width

Type: int|null

Width of the video in pixels.

height

Type: int|null

Height of the video in pixels.

raw

Type: array

Array of raw data for any additional information provided by the API.

Methods

getSource()

Returns: verbb\videopicker\base\SourceInterface|null

Returns the Source for the video.

getFormattedDuration()

Returns: string

Returns a human-readable format of the duration (e.g., 01:23:15).

getDuration8601()

Returns: string

Returns the duration of the video in ISO8601 format.

getThumbnail($width = 600)

Returns: string|null

Retrieves the URL for the closest available thumbnail to the specified width.

getEmbedHtml($options = [])

Returns: string|null

Returns the HTML embed code for the video, with optional customisation parameters.

getEmbedUrl($options = [])

Returns: string|null

Retrieves the direct URL to embed the video with optional customisation parameters.