Skip to content
JIX edited this page Jul 14, 2020 · 1 revision

Purpose

The video field allows users to select all elements, needed for an HTML5 video tag, including:

  • Multiple video files, usable for the sources of the field.
  • A poster, which will can be displayed before the video is played.

video-field

Settings and Usage

The only additional settings for the video field are its output width and settings. In in the interface (the "Output Settings" tab) and in PHP, those settings expect a number in pixels. The PHP methods, used for the output size are set_output_width( $width ) and set_output_height( $height ).

Field::create( 'video', 'header_video' )
	->set_output_width( 1920 )
	->set_output_height( 1080 )

Using the value in the front-end works both with get_value and the_value.

If you are using get_value functions, you will receive an array, which contains two elements:

  1. videos is an array, which contains the IDs of the videos.
  2. poster may be a single ID, which is used for the poster.

Using the_value will generate a complete video tag.

<?php the_value( 'header_video' ) ?>
Clone this wiki locally