私はこの問題を抱えています。
ここでカスタムフィールドにこれを渡します
(notice the "autoplay=1")
しかし、...を使用してテーマにビデオをロードすると、ビデオは正常に表示されますが、通過する変数をwp_oembed_get
リッスンしません。autoplay=1
ページの読み込み時に動画を再生する必要があります。
それを行う方法は、ワードプレスフィルターを使用することだと思います:
function modify_youtube_embed_url($html) {
return str_replace("?feature=oembed", "?feature=oembed&autoplay=1", $html);
}
add_filter('oembed_result', 'modify_youtube_embed_url');
関数 wp_oembed_get を検索し、引数を使用して自動再生を渡します...正常に動作するはずです。&autoplay ではなく、ビデオの URL を貼り付けるだけです。これを関数の args 部分にコーディングします。
これは、wp-includes/media.php の wp_oembed_get() 関数を次のように変更することで簡単に修正できます。
function wp_oembed_get( $url, $args = '' ) {
// Manually build the IFRAME embed with the related videos option disabled and autoplay turned on
if(preg_match("/youtube.com\/watch\?v=([^&]+)/i", $url, $aMatch)){
return '<iframe width="560" height="315" src="http://www.youtube.com/embed/' . $aMatch[1] . '?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
}
require_once( ABSPATH . WPINC . '/class-oembed.php' );
$oembed = _wp_oembed_get_object();
return $oembed->get_html( $url, $args );
}