WordPRESS YouTubu & 外部コンテンツ

funcitons.php

----

// コンテンツ最大幅
if(!isset($content_width)) {
$content_width = 747;
}

// YouTube のビデオ :<div>でマークアップ
function ytwrapper($return, $data, $url) {
if($data->provider_name == 'YouTube') {
return '<div class="ytvideo">' . $return . '</div>';
} else {
return $return;
}
}
add_filter('oembed_dataparse', 'ytwrapper', 10,3);

// YouTubeのビデオ:キャッシュをクリア
function clear_ywrapper($post_id) {
global $wp_embed;
$wp_embed->delete_oembed_caches($post_id);
}
add_filter('pre_post_updata', 'clear_ywrapper');

-----

style.css

--

/* YouTube のビデオ */
.ytvideo {position: relative;width: 100%; height:0; padding-top: 56.25%;overflow: hidden;
margin-top: 30px; margin-bottom: 30px;}

.ytvideo iframe{position: absolute; top:0; left: 0; width: 100%; height: 100%;}