How to set youtube thumbnail from youtube embed code as featured image in wordpress? How to set youtube thumbnail from youtube embed code as featured image in wordpress? wordpress wordpress

How to set youtube thumbnail from youtube embed code as featured image in wordpress?


The format for pulling the large image from a YouTube video is this http://img.youtube.com/vi/A4a0xZMMlqE/0.jpg just replace "A4a0xZMMlqE" with the video id.

I think the easiest way to set this up would be to forget about using it as a featured image but just pulling it into the template dynamically.

So in your post, make a custom field that will hold the YouTube video ID and in the template do something like:

<img src="http://img.youtube.com/vi/<?php echo get_post_meta($post->ID,'youtubeId');?>/0.jpg"/>

Does that solve your problem?

Otherwise if you're looking at really making it the featured image then you're probably looking at developing a custom plugin: http://net.tutsplus.com/tutorials/wordpress/creating-a-custom-wordpress-plugin-from-scratch/ which will most likely make use of wp_insert_attachment

I also just found media_sideload_image which I wasn't aware of. It will pull an image from a URL (i.e. the youtube link above) and attach it to a post.