Adding bootstrap classes to video shortcodes

This is how I bootstrapped youtube embeds in one of my projects.

/**
 * Responsive Youtube embeds.
 */
add_filter( 'embed_oembed_html', function( $html, $url, $attr, $post_ID ) {
  if ( false !== stripos( $html, '<iframe ' ) && false !== stripos( $html, '.youtube.com/embed' ) ) {
    $html = sprintf('<div class="embed-responsive embed-responsive-16by9">%s</div>', $html );
  }

  return $html;
}, 10, 4);

Please note this snippet is using anonymous functions which are available in > PHP 5.3

tech