Video Field
A video: either a file from a media source, or a link to YouTube or Vimeo. The field works out which it is and fetches what it can about it.
Settings: source and file path, as for a file.
What arrives in the template depends on the provider
Every case gives you provider, url and embed_video. Beyond that they differ, and the difference bites:
| Provider | thumbnail |
|---|---|
youtube | An array of sizes — default, medium, high, standard, maxres, each with url, width, height. Plus a ready preview |
vimeo | A string with the URL, plus thumbnail_width and thumbnail_height |
video (an uploaded file) | None — there is nothing to fetch it from |
thumbnail is an array for YouTube and a string for Vimeo
The same key holds different shapes. A template written against a YouTube video and then fed a Vimeo one prints Array — or nothing. Branch on provider, or use preview where it exists.
YouTube and Vimeo:
html
<iframe src="{$video.embed_video}" width="600" height="400" frameborder="0"></iframe>An uploaded file:
html
<video controls poster="/{$video.preview}">
<source src="/{$video.url}">
</video>Title and description come from the provider, so an embedded video can be labelled without retyping anything.