o la variable que quiero (la id de youtube) es otra? estoy algo perdido. aqui os dejo el codigo:
Código:
<?php function print_video_thumb_backward($post, &$thumb_url) { $video_id = get_post_meta($post->ID, 'vids', true); if (! empty($video_id)) { $thumb_url = 'http : / /img.youtube.com/vi/' . $video_id . '/2.jpg'; return 1; } } function print_video_thumb_supported_site($post,&$thumb_url) { $content = $post->post_content; if (preg_match(video_pattern(),$content, $match)) { // video found $content = $match[0]; preg_match('/^\[(\w+)/',$content,$video_type); switch ($video_type[1]) { case 'youtube': preg_match('/v=(.*?)[\s&\[]/',$content,$video_id); $url = 'h t t p : / / youtube.com/v/' . $video_id[1]; $data = get_url($url); preg_match('/v=(.*?)[\s&\[]/',$content,$video_id); $thumb_url = 'h t t p : / / img.youtube.com/vi/' . $video_id[1] . '/2.jpg'; return 1; } } } function print_video_thumb_custom_field($post,&$thumb_url) { $t = get_post_meta($post->ID, 'video_thumb', true); if (! empty($t)) { $thumb_url = $t; return 1; } } function print_video_thumb_first_post_image($post,&$thumb_url) { $content = $post->post_content; if (preg_match('/<img[[:alnum:]\s-_=;:"\/]+src="(.*?)"/',$content, $match)) { $thumb_url = $match[1]; return 1; } } function print_video_thumb_unsupported_site($post,&$thumb_url) { $content = $post->post_content; if (preg_match(video_pattern(),$content, $match)) { // video found $content = $match[0]; preg_match('/^\[(\w+)/',$content,$video_type); switch ($video_type[1]) { case 'myspace': $thumb_url = get_template_directory_uri() . '/images/thumb_myspace.png'; return 1; } } } function print_video_thumb($post) { print_video_thumb_backward($post,$thumb_url) || print_video_thumb_custom_field($post,$thumb_url) || print_video_thumb_supported_site($post,$thumb_url) || print_video_thumb_first_post_image($post,$thumb_url) || print_video_thumb_unsupported_site($post,$thumb_url); echo get_video_thumb(get_permalink($post->ID), $post->post_title, $thumb_url); } function get_video_thumb($url,$title,$img) { return '<a href="' . $url . '" title="' . $title . '"><img src="' . $img . '" alt="' . $title . '" width="130px" height="97px" /></a>'; } ?>