WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp video shortcode

Description

Implements the functionality of the Video Shortcode for displaying (and playing) video-files in a post. Conditionally adds HTML video tag (with media player, sized to $content_width defined in active Theme) or fallback HTML.

Default WordPress supported video formats are: mp4, m4v, webm, ogv, wmv, flv.

Usage

 <?php wp_video_shortcode$attr ?> 

Parameters

$attr
(array) (required) Attributes of the shortcode. The following attributes are supported:
Default: None

Attributes

src
(string) (optional) The source of your video file. If not included it will auto-populate with the first video file attached to the post. You can use the following options to define specific filetypes, allowing for graceful fallbacks:
  • 'mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv'
Default: First video file attached to the post
poster
(string) (optional) Defines image to show as placeholder before the media plays.
Default: None
loop
(string) (optional) Allows for the looping of media. Defaults to "off".
  • "off" - ("default") does not loop the media
  • "on" - media will loop to beginning when finished and automatically continue playing
Default: "off"
autoplay
(string) (optional) Causes the media to automatically play as soon as the media file is ready. Defaults to "off".
  • "off" - ("default") does not automatically play the media
  • "on" - Media will play as soon as the media is ready
Default: "off"
preload
(string) (optional) Specifies if and how the video should be loaded when the page loads. Defaults to "metadata".
  • "metadata" - ("default") only metadata should be loaded when the page loads
  • "none" - the video should not be loaded when the page loads
  • "auto" - the video should be loadaded entirely when the page loads
Default: "metadata"
width
(integer) (required) Defines width of the media. Value is automatically detected on file upload.
Default: 640
height
(integer) (required) Defines height of the media. Value is automatically detected on file upload.
Default: 360

Return

(string) 
HTML content to display video.

Example

Change Log

Source File

wp_video_shortcode() is located in wp-includes/media.php.

Related

Shortcode API

Video: wp_video_shortcode(), wp_get_video_extensions(), get_attached_video(), get_attached_media(), get_embedded_video(), get_embedded_media(), wp_embed_handler_video(), wp_mediaelement_fallback(), wp_read_video_metadata(), wp_add_id3_tag_data(), the_post_format_video(), get_the_post_format_media(), get_content_video(), get_content_media()

See also index of Function Reference and index of Template Tags.