In a WordPress related project I’m currently involved in, there’s a scenario where the content is a video which is published on YouTube. To simplify things and prevent user from repeating useless task, I made this workflow:

  1. Create a custom post type (CPT) named video
  2. Create a custom meta box where people can saved the URL. The URL will be saved as post meta

The theme later will pull featured image and automatically embed the video on the CPT’s single page. I made these simple functions to deal with this task:

  1. Getting YouTube ID by URL
  2. Getting YouTube thumbnail image by video ID (and optionally the wanted image size)
  3. A shortcut: Getting thumbnail image by URL and size

Here’s how I did it:

Share Your Thought