Created
November 4, 2015 10:59
-
-
Save korobochkin/2cfc9db9aa7300f0c00f to your computer and use it in GitHub Desktop.
Резиновые плееры YouTube и Vimeo
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
<?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