Advertisement
cipher87

Video Background Poster

May 1st, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. function avia_html5_video_embed($path, $image = "", $types = array('webm' => 'type="video/webm"', 'mp4' => 'type="video/mp4"', 'ogv' => 'type="video/ogg"'))
  2.     {
  3.  
  4.         preg_match("!^(.+?)(?:\.([^.]+))?$!", $path, $path_split);
  5.  
  6.         $output = "";
  7.         if(isset($path_split[1]))
  8.         {
  9.             if(!$image && avia_is_200($path_split[1].'.jpg'))
  10.             {
  11.                 $image = 'poster="'.$path_split[1].'.jpg"'; //poster image isnt accepted by the player currently, waiting for bugfix
  12.             }
  13.  
  14.             $uid = 'player_'.get_the_ID().'_'.mt_rand().'_'.mt_rand();
  15.  
  16.             $output .= '<video class="avia_video" '.$image.' controls id="'.$uid.'" preload="metadata" >';
  17.  
  18.             foreach ($types as $key => $type)
  19.             {
  20.                 if($path_split[2] == $key || avia_is_200($path_split[1].'.'.$key))
  21.                 {
  22.                     $output .= '    <source src="'.$path_split[1].'.'.$key.'" '.$type.' />';
  23.                 }
  24.             }
  25.  
  26.             $output .= '</video>';
  27.         }
  28.  
  29.         return $output;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement