Skip to content

Instantly share code, notes, and snippets.

@korobochkin
Created November 4, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korobochkin/2cfc9db9aa7300f0c00f to your computer and use it in GitHub Desktop.
Save korobochkin/2cfc9db9aa7300f0c00f to your computer and use it in GitHub Desktop.
Резиновые плееры YouTube и Vimeo
<?php
function kk_embed_oembed_html_adaptive ($cache, $url, $attr, $post_ID) {
/**
* Отступ в 6 символов в начале ссылки, потому что есть http://
* (для https:// тоже сработает).
*/
if (
strpos ($url, 'youtu', 6)
||
strpos ($url, 'vimeo', 6)
) {
$cache = '<div class="embed-responsive embed-responsive-16by9">' . $cache . '</div>';
} return $cache;
}
add_filter ('embed_oembed_html', 'kk_embed_oembed_html_adaptive', 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment