2017-10-10 8 views
0

私のワードプレステーマのビデオアップローダを追加するのに苦労している人は誰でも助けてくれますか?私のWordpressのカスタマイザにビデオアップローダを追加する

私はのfunctions.phpファイルでこれを持っている:

 // Andys Video Section 

    $wp_customize->add_section("Videosection", array(
     "title" => __("Video Section", "customizer_ads_sections"), 
     "priority" => 20, 
    )); 
$wp_customize->add_setting('video_upload', 
    array(
     'default' => '', 
     'transport' => 'refresh', 
     'sanitize_callback' => 'absint', 
      'type' => 'theme_mod', 
    ) 
); 

$wp_customize->add_control(new WP_Customize_Media_Control($wp_customize, 'video_upload', 
    array(
     'label' => __('Default Media Control'), 
     'description' => esc_html__('This is the description for the Media Control'), 
     'section' => 'Videosection', 
     'mime_type' => 'video', // Required. Can be image, audio, video, application, text 
     'button_labels' => array(// Optional 
     'select' => __('Select File'), 
     'change' => __('Change File'), 
     'default' => __('Default'), 
     'remove' => __('Remove'), 
     'placeholder' => __('No file selected'), 
     'frame_title' => __('Select File'), 
     'frame_button' => __('Choose File'), 

    ) 
    ) 
)); 

そして、この私のページのテンプレートに:

動画がアップロードされていませんが
<div class="video-container"> 
     <button style="position:absolute; top:50%; left:50%;" onclick="playPause(); return false;">Click to start</button> 

      <video loop controls poster="http://test.guerrilla.nz/wp-content/themes/advocate/images/David_Buckingham.jpg"> 
<?php echo get_theme_mod('video_upload') ?> 
     <source src="<?php echo get_theme_mod('video_upload') ?>" width="100" type="video/mp4"> 
      <source src="<?php echo get_theme_mod('video_upload') ?>" type="video/ogg"> 
      <source src="<?php echo get_theme_mod('video_upload') ?>" type="video/ogg"> 
      Your browser does not support the video tag. 
    </video> 
     </div> 

、誰でも助けることができますか? [OK]を、

function andys_theme_customizer($wp_customize) { 



     // Andys Video Section 

    $wp_customize->add_section("Videosection", array(
     "title" => __("Video Section", "customizer_ads_sections"), 
     "priority" => 20, 
    )); 

$wp_customize->add_setting('video_upload', 
    array(
     'default' => '', 
     'transport' => 'refresh', 
     'sanitize_callback' => 'absint', 
      'type' => 'theme_mod', 
    ) 
); 

$wp_customize->add_control(new WP_Customize_Media_Control($wp_customize, 'video_upload', 
    array(
     'label' => __('Default Media Control'), 
     'description' => esc_html__('This is the description for the Media Control'), 
     'section' => 'Videosection', 
     'mime_type' => 'video', // Required. Can be image, audio, video, application, text 
     'button_labels' => array(// Optional 
     'select' => __('Select File'), 
     'change' => __('Change File'), 
     'default' => __('Default'), 
     'remove' => __('Remove'), 
     'placeholder' => __('No file selected'), 
     'frame_title' => __('Select File'), 
     'frame_button' => __('Choose File'), 

    ) 
    ) 
)); 



} 

add_action('customize_register', 'andys_theme_customizer'); 
+0

これはfunctions.phpの完全なコードブロックですか?私は関数の定義を見ていないし、add_actionの部分です。 –

+0

こんにちはアルスラーン: ここでは、追加のアクションです: add_action( 'customize_register'、 'andys_theme_customizer'); そして、関数の定義については、上記のコードは内部です: 関数andys_theme_customizer($ wp_customize){} – Afisher

答えて

0

は、フル機能がある

<div class="video-container"> 
<?php 
$id = get_theme_mod('video_upload'); 

$attr = array(
    'src' => wp_get_attachment_url($id) 
); 

echo wp_video_shortcode($attr); 
?> 
</div> 

は、ドキュメントwp_video_shortcodeを見てください。

0

おかげので、これにテンプレートにコードを変更してみてください:ここで

+0

おかげアルスラーン、これはしかし、私のCSSクラスは、もは​​や今動作しませんどのように私はresponcivelyこのビデオをサイズない、素晴らしい作品ポスター画像やその他の属性を追加できますか? – Afisher

+0

。ビデオコンテナ{ 位置:相対; パッディングボトム:56.25%; パディングトップ:30px; 高さ:100%; オーバーフロー:非表示。 } .video-container iframe、.video-containerオブジェクト、.video-container埋め込み、.video-containerビデオ{ 位置:絶対; display:ブロック; トップ:0; 左:0; 身長:100%!重要; min-width:100%; 最小高さ:100%; z-インデックス:1000; オーバーフロー:非表示。 パディング:100px 100px 100px 100px; } – Afisher

+0

あなたは、ポスター、自動再生、幅、高さなど –

関連する問題