Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressでYouTube動画のサムネイルを追加する方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

人気サイトがトップページにYouTube動画のサムネイルを使っているのを見たことがあるだろうか?もしあなたがYouTubeやVimeoなどのサイトで動画チャンネルを運営しているのであれば、あなたのブログのフロントページやアーカイブページに動画を含む投稿のサムネイルをすべて表示することができます。この投稿では、WordPressでYouTube動画のサムネイルを追加する方法を紹介します。

An example of video thumbnails in WordPress

動画のサムネイルとWordPressの投稿サムネイル

WordPressには、おすすめ画像や投稿サムネイルを追加する機能がビルトインされており、ほとんどのWordPressテーマがこの機能をサポートしています。しかし、YouTubeの動画コンテンツを強調したい場合は、動画サムネイルでそのコンテンツを紹介したいと思うでしょう。この投稿では、WordPressの初期設定である投稿サムネイル機能を使って、この機能を実現するお手伝いをします。

WordPressで動画サムネイル・プラグインを設定する

まず最初に行う必要があるのは、Video Thumbnailsプラグインをインストールして有効化することです。プラグインを有効化した後、Settings ” Video Thumbnailsでプラグインの設定を行う必要があります。

Setting up video thumbnails

設定画面では、サムネイルをメディアライブラリに保存することを選択することをお勧めします。そうすることで、サイトへの外部httpリクエストが減り、ページの読み込みが速くなります。投稿タイプセクションで、プラグインは投稿、ページ、もしサイトに投稿タイプがあればカスタム投稿タイプを表示します。プラグインに動画リンクをスキャンさせたい投稿タイプを選択してください。このページの最後のオプションは、カスタムフィールドを選択することです。WordPress用の動画プラグインの中には、動画のURLをカスタムフィールドに保存するものがあり、そのようなプラグインを使用している場合は、ここにそのカスタムフィールドを入力する必要があります。その後、変更を保存ボタンをクリックします。

設定ページでは、プロバイダータブも表示されます。動画の共有にVimeoを使用している場合は、Vimeoでアプリを作成し、クライアントID、クライアントシークレット、アクセストークン、アクセストークンシークレットの値をここに入力する必要があります。

Adding Vimeo app credentials

Mass Actionsタブでは、公開する投稿の動画をスキャンして投稿サムネイルを生成することができます。このプラグインには、動画のサムネイルをすべて消去し、投稿から添付ファイルとして削除するボタンも用意されています。

Scan posts to generate video thumbnails

WordPress投稿に動画サムネイルを作成する

プラグインの設定が完了したので、WordPressの投稿に動画のURLを追加して投稿サムネイルを作成してみよう。そのためには、WordPressの投稿を作成または編集し、投稿編集エリアに動画のURLを追加する必要があります。投稿を公開すると、プラグインが動画のサムネイルを生成し、投稿に追加したことがわかります。

Adding a video in WordPress Post and Generating a Video Thumbnail

WordPressテーマで動画のサムネイルを表示する

動画サムネイルプラグインはWordPressの投稿サムネイル機能を利用しています。ほとんどの WordPress テーマは、投稿サムネイルを自動的に表示するように設定されています。これは、テーマが投稿コンテンツまたは抜粋と一緒に動画のサムネイルを自動的に表示することを意味します。しかし、あなたのテーマが動画のサムネイルを表示しない場合は、テーマファイルを編集し、サムネイルを表示したいテンプレートにこのコードを追加する必要があります。

[cbk1]

WordPressで動画のサムネイルに再生ボタンを追加する方法

WordPressの投稿に動画のサムネイルを表示できるようになった今、通常の画像のサムネイルと動画のサムネイルを区別したいと思うかもしれません。これにより、ユーザーは投稿日に動画があることを知ることができ、再生ボタンをクリックして動画投稿を表示することができます。ここでは、条件分岐タグを使って動画のサムネイルと通常の投稿サムネイルを区別し、再生ボタンを追加する方法を紹介します。

この方法を使用するには、動画投稿を特定のカテゴリー、例えば「動画」で公開する必要があります。そして、index.php、archive.php、category.php、content.phpのようなテーマのテンプレートファイルの中で、このコードの行を探してください:

[cbk2]

このコードを次のコードに置き換える必要があります:

[cbk3]

このコードは、投稿サムネイルの後に<span class="playbutton"?></span>を追加します。次のステップは、メディア ” 新規: 画面から画像ファイルをアップロードすることです。この画像が再生ボタンとして使用されます。画像ファイルをアップロードしたら、画像の横にある編集リンクをクリックして、画像ファイルの場所をメモしてください。

最後のステップは、再生ボタンを表示することです。動画のサムネイルに再生ボタンを表示し、配置するためにCSSを使用します。そのためには、テーマまたは子テーマのスタイルシートにこのCSSコードをコピー&ペーストする必要があります

[cbk4]

背景画像のURLを、先ほどアップロードした再生ボタン画像ファイルのURLに置き換えるのを忘れないでください。これですべてです。これで動画のサムネイルファイルに再生ボタンが付いたはずです。

この投稿が、WordPressでYouTube動画をサムネイルで強調するのにお役に立てば幸いです。フィードバックやご質問は、コメントを残すか、Twitterでフォローしてください。

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

44件のコメント返信を残す

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Peter says

    It is amazing that it still works!
    However does somebody know why it is not getting a thumbnail from a YT playlist?
    i´ve several posts with playlist and the image is always a grey “Video is not found” image

    • WPBeginner Support says

      The plugin was created for videos and not entire playlists, you would need to reach out to the plugin’s author for including playlist functionality.

      管理者

  3. Mohammad says

    Hi
    I try to use this plugin but it doesn’t work for me and the developer in support forums doesn’t answer most of the unsolved topics. In debugging page when I try “Test Markup for Video” I get this error:

    Thumbnail found, but it may not exist on the source server. If opening the URL below in your web browser returns an error, the source is providing an invalid URL. Thumbnail URL:
    what’s the problem?

  4. Neon emmanuel says

    what if i want three parameters, 1 a fall back when there is no thumbnail, two i fall back if it is video, (i.e) adding a play button overlay to it , and three a fall back it it is video with an overlay play icon on it.

  5. franck says

    Hi folks,

    is anybody know how to remove related video when Youtube video is played till the end in video gallery plugin from Huge IT?

  6. Ernesto says

    How do I remove the image from inside the entrance? I want input into the video display and no image

  7. Rihan says

    And wordpress 4.0 I add the video (youtube) URL in the post edit area and its showing me a video player :( on the video thumb are i can see this text only (No video thumbnail for this post.) not working!

    any Idea :) thanks

  8. Mauro Scarpa says

    Hi! Great website and post, i have a question, if then I want to share my post on facebook, will appear whit the play button also? Thanks

  9. Piet says

    Cool plugin and tutorial. Instead of showing a play button image, I would like to suggest using a font icon, for example from FontAwesome.

  10. WPBeginner Staff says

    TCB: if you are using WordPress SEO plugin then youc an try this method. Once the video thumbnail plugin has fetched the thumbnail image for your video, you need to find its location in your media library and copy the URL. After that remove the video thumbnail image from the post. In the WordPress SEO meta box on the post editor, click on the social tab, and paste the link next to the facebook image field.

  11. TCB says

    Is it possible to use the video thumbnail as post image on facebook?
    That would be great because I don’t want to the show the picture as featured image.

  12. Megha Verma says

    I am facing a problem as the play button is showing only on the first post….due to absolute position….not on other post’s images…

  13. Sutherland Boswell says

    Great tutorial! As the developer I love to get feedback from users and work on easy solutions for the most requested features. Overlaying a play button and making the video actually play when clicking the thumbnail are two of the most requested features, but they’re both highly dependent on the theme. Learning to modify a theme on your own can be rewarding, so don’t be afraid to give it a shot!

    PS – I hope everyone will check out the pro version!

    • Jesse says

      Hi Sutherland.

      I’ve read such good things about your plugin and I’m eager to try it.

      However, when using your plugin to scan for video files, it finds all 22 videos under the ‘video’ page which they are posted. The problem is it isn’t finding any thumbnails.

      After reading your various support replies to similar issues, as well as your instructions, i sought to find out whether my theme (metric, by grandpixels) is using a custom field. I have been unsuccessful in finding this information.

      Do you have suggestions on how to make this work?

      Thanks,

      Jesse

  14. Audee says

    What if I want to display post thumbnail only for posts filed under video ‘Post Format’ ?

    Thank you for sharing article about this plugin!

      • Alex says

        Hi Sutherland Boswell,

        i use your plugin for Detube theme, the problem is there is no <a href="”> code line in those files: index.php, archive.php, category.php..
        Do you have any idea or a way to make it work in Detube theme?

        Thanks in advance!

        • Alex says

          i would be so glad if someone has an idea and could answer my question. I’ve been working for many hours to get this code works on Detube, but no succes untill now…
          Could someone here please help me?

  15. Ahmad Rafi Maseer says

    HOw to play directly in thumbnail so the user should not go to post page to play the video???

  16. Sue Anne says

    Thanks SO much for the great instruction on putting a video and video thumbnail on my WordPress blog. It took about 5 minutes and I’m no techie!

  17. Pali Madra says

    Hi!

    Great website and one of my favorite post.

    I had a related question. I’m adding video by placing the URL in the HTML code of the posts but I also want to show a caption below it. Is that possible without using a plugin?

    Thanks in advance

  18. Tiguan says

    The ‘span’ must be placed inside the thumbnail’s hyperlink tags, otherwise the image link over play button will be disabled. So the correct code will be:

    However, it’s a nice tutorial.

  19. gottfrid q. says

    > This will let your users know that there is a video in the post, and they can click on the play button to view the video post.
    I don’t want to disappoint you, but the button (spin) don’t have any click method.
    How exactly this button was supposed to work and how to implement it?

    Thanks for your time.

  20. Akash says

    And. how to implement Play Button in GENESIS Theme? there is no index.php, archive.php, category.php, or content.php file there to add the code.

    Thanks.

  21. Akash says

    But what will be the size of the Video Thumbnail? Will it be same as the image thumbnail already set in the blog?

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。