wp_embed_handler_video

Video embed handler callback.

Description

(string) wp_embed_handler_video( (array) $matches, (array) $attr, (string) $url, (array) $rawattr ); 

Returns (string)

The embed HTML.

Parameters (4)

0. $matches (array)
The RegEx matches from the provided regex when calling wp_embed_register_handler().
1. $attr (array)
Embed attributes.
2. $url (string)
The original URL that was matched by the regex.
3. $rawattr (array)
The original unmodified attributes.

Usage

  1. if ( !function_exists( 'wp_embed_handler_video' ) ) { 
  2. require_once ABSPATH . WPINC . '/embed.php'; 
  3.  
  4. // The RegEx matches from the provided regex when calling wp_embed_register_handler(). 
  5. $matches = array(); 
  6.  
  7. // Embed attributes. 
  8. $attr = array(); 
  9.  
  10. // The original URL that was matched by the regex. 
  11. $url = ''; 
  12.  
  13. // The original unmodified attributes. 
  14. $rawattr = array(); 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wp_embed_handler_video($matches, $attr, $url, $rawattr); 
  18.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/embed.php  
  1. function wp_embed_handler_video( $matches, $attr, $url, $rawattr ) { 
  2. $dimensions = ''; 
  3. if ( ! empty( $rawattr['width'] ) && ! empty( $rawattr['height'] ) ) { 
  4. $dimensions .= sprintf( 'width="%d" ', (int) $rawattr['width'] ); 
  5. $dimensions .= sprintf( 'height="%d" ', (int) $rawattr['height'] ); 
  6. $video = sprintf( '[video %s src="%s" /]', $dimensions, esc_url( $url ) ); 
  7.  
  8. /** 
  9. * Filters the video embed output. 
  10. * @since 3.6.0 
  11. * @param string $video Video embed output. 
  12. * @param array $attr An array of embed attributes. 
  13. * @param string $url The original URL that was matched by the regex. 
  14. * @param array $rawattr The original unmodified attributes. 
  15. */ 
  16. return apply_filters( 'wp_embed_handler_video', $video, $attr, $url, $rawattr );