Skip to content

Instantly share code, notes, and snippets.

@hatsumatsu
Created April 9, 2015 15:45
Show Gist options
  • Save hatsumatsu/e5df3b0bf9ac3389c0b0 to your computer and use it in GitHub Desktop.
Save hatsumatsu/e5df3b0bf9ac3389c0b0 to your computer and use it in GitHub Desktop.
/**
* Wrap oembed in <div>
* @param string $html original markup
* @param string $url URL
* @param array $attributes config
* @param int $id post ID
* @return string modified markup
*/
function wrap_oembed( $html, $url, $attributes, $id ) {
$class = '';
if( strpos( $url, 'youtu' ) || strpos( $url, 'vimeo' ) ) {
$class .= ' embed-video';
}
return '<div class="' . esc_attr( $class ) . '">' . $html . '</div>';
}
add_filter( 'embed_oembed_html', 'wrap_oembed', 99, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment