Created
April 9, 2015 15:45
-
-
Save hatsumatsu/e5df3b0bf9ac3389c0b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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