Reference

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

The video’s ID on the provider’s platform.

url

The video’s URL on the provider’s platform.

sourceHandle

The handle of the Video Picker source the video came from. getSource() uses it to load that source.

date

The date the video was published or created, or null when the provider doesn’t supply one.

duration

The video’s length in seconds, or null when the provider doesn’t supply one.

duration8601

The video’s length in ISO 8601 format, such as PT4M13S, or an empty string when the duration is unknown. This calls getDuration8601().

plays

The number of times the video has been played, when the provider reports it.

authorName

The name of the video’s author or channel.

authorUrl

The URL of the author’s profile or channel.

authorUsername

The author’s username on the provider’s platform.

thumbnails

A list of thumbnail images. Each item has a url and may include integer width and height values. Use getThumbnail() to pick one by width.

title

The video’s title.

description

The video’s description.

private

Whether the provider marks the video as private.

width

The video’s width in pixels, when the provider reports it.

height

The video’s height in pixels, when the provider reports it.

raw

The full data the provider returned for the video, for details Video Picker doesn’t map to its own properties.

Methods

getSource()

Returns the Source the video came from, or null when that source no longer exists.

getFormattedDuration()

Returns the video’s length for display, as mm:ss or hh:mm:ss when it’s an hour or longer. A duration of zero, which providers report for live streams, returns ∞, and an unknown duration returns an empty string.

getDuration8601()

Returns the video’s length in ISO 8601 format, such as PT1H23M15S, for use in structured data. An unknown duration returns an empty string.

getThumbnail()

Returns: string|null

Returns the URL of the thumbnail closest to the width you give, or the first thumbnail when none have a width. Returns null when the video has no thumbnails.

getEmbedHtml()

Returns: string|null

Returns the iframe HTML for the video, using the field’s embed defaults. options can include player settings such as autoplay, muted, loop, controls and start, iframe attributes such as class or title, and other query parameters. Returns null when the video’s source no longer exists, unless it’s a generic embed from a URL.

getEmbedUrl()

Returns: string|null

Returns the embed URL for the video, with the same options as getEmbedHtml(). Returns null when the video’s source no longer exists, unless it’s a generic embed from a URL.