vine_embed_video

Vine embed code:.

Description

vine_embed_video( $matches, $attr, $url, $rawattr ); 

URL example: https://vine.co/v/bjHh0zHdgZT/

Embed shortcode examples: [embed]https://vine.co/v/bjHh0zHdgZT[/embed] [embed width="300"]https://vine.co/v/bjHh0zHdgZT[/embed] [embed type="postcard" width="300"]https://vine.co/v/bjHh0zHdgZT[/embed]

Parameters (4)

0. $matches
The matches.
1. $attr
The attr.
2. $url
The url.
3. $rawattr
The rawattr.

Usage

  1. if ( !function_exists( 'vine_embed_video' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/shortcodes/vine.php'; 
  3.  
  4. // The matches. 
  5. $matches = null; 
  6.  
  7. // The attr. 
  8. $attr = null; 
  9.  
  10. // The url. 
  11. $url = null; 
  12.  
  13. // The rawattr. 
  14. $rawattr = null; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = vine_embed_video($matches, $attr, $url, $rawattr); 
  18.  

Defined (1)

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

/modules/shortcodes/vine.php  
  1. function vine_embed_video( $matches, $attr, $url, $rawattr ) { 
  2. static $vine_flag_embedded_script; 
  3.  
  4. $max_height = 300; 
  5. $type = 'simple'; 
  6.  
  7. // Only allow 'postcard' or 'simple' types 
  8. if ( isset( $rawattr['type'] ) && $rawattr['type'] === 'postcard' ) 
  9. $type = 'postcard'; 
  10.  
  11. $vine_size = Jetpack::get_content_width(); 
  12.  
  13. // If the user enters a value for width or height, we ignore the Jetpack::get_content_width() 
  14. if ( isset( $rawattr['width'] ) || isset( $rawattr['height'] ) ) { 
  15. // 300 is the minimum size that Vine provides for embeds. Lower than that, the postcard embeds looks weird. 
  16. $vine_size = max( $max_height, min( $attr['width'], $attr['height'] ) ); 
  17.  
  18. if ( empty( $vine_size ) ) { 
  19. $vine_size = $max_height; 
  20.  
  21. $url = 'https://vine.co/v/' . $matches[1] . '/embed/' . $type; 
  22. $vine_html = sprintf( '<span class="embed-vine" style="display: block;"><iframe class="vine-embed" src="%s" width="%s" height="%s" frameborder="0"></iframe></span>', esc_url( $url ), (int) $vine_size, (int) $vine_size ); 
  23.  
  24. if ( $vine_flag_embedded_script !== true ) { 
  25. $vine_html .= '<script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>'; 
  26. $vine_flag_embedded_script = true; 
  27.  
  28. return $vine_html;