Advertisement
phpface

Changing videojs player

Jul 26th, 2023
1,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. /**
  2.  *
  3.  * Player filter
  4.  *
  5.  * @param string $player default videojs player output
  6.  * @param array $setup
  7.  * @param int|url|embed|iframe $source
  8.  *
  9.  */
  10. add_filter('streamtube/player/file/output', function( $player, $setup, $source ){
  11.  
  12.     wp_deregister_script( 'videojs' );
  13.     wp_deregister_style( 'videojs' );
  14.  
  15.     ob_start();
  16.  
  17.     ?>
  18.     <video controls>
  19.        
  20.         <?php printf(
  21.             '<source src="%s" type="%s">',
  22.             wp_attachment_is( 'video', esc_attr( $source ) ) ? wp_get_attachment_url( $source ) : $source,
  23.             wp_attachment_is( 'video', esc_attr( $source ) ) ? get_post_mime_type( $source ) : 'unknown'
  24.         );?>
  25.  
  26.     </video>
  27.     <?php
  28.  
  29.     return ob_get_clean();
  30.  
  31. }, 10, 3 );
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement