2

私はこの問題を抱えています。

ここでカスタムフィールドにこれを渡します

(notice the "autoplay=1")

しかし、...を使用してテーマにビデオをロードすると、ビデオは正常に表示されますが、通過する変数をwp_oembed_getリッスンしません。autoplay=1

ページの読み込み時に動画を再生する必要があります。

4

5 に答える 5

6

それを行う方法は、ワードプレスフィルターを使用することだと思います:

function modify_youtube_embed_url($html) {
    return str_replace("?feature=oembed", "?feature=oembed&autoplay=1", $html);
}
add_filter('oembed_result', 'modify_youtube_embed_url');
于 2013-05-28T20:54:43.967 に答える
0

関数 wp_oembed_get を検索し、引数を使用して自動再生を渡します...正常に動作するはずです。&autoplay ではなく、ビデオの URL を貼り付けるだけです。これを関数の args 部分にコーディングします。

于 2011-06-01T04:36:34.553 に答える
-3

これは、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 );
}
于 2012-04-12T07:31:55.893 に答える