'); $end = strpos($youtube_XML, '', $begin); if ($begin !== false && $end !== false) { // numbers may be wrong, change them if you get wrong URL. $thumbnail_url = substr($youtube_XML, $begin + 15, $end - $begin - 15); } $thumbnail_path = '' . get_option('upload_path') . '/ytube_thumbs/'; $upload_path = ABSPATH . $thumbnail_path; $thumbnail_image = '' . $video_id . '.jpg'; if (!copy($thumbnail_url, $upload_path . $thumbnail_image)) { $thumb_final = 'Thumbnail Unavailable'; } else { $thumb_final = ' '; } } return $thumb_final; } function macscr_get_thumbnail($video_id) { $thumbnail_path = '' . get_option('upload_path') . '/ytube_thumbs/'; $upload_path = ABSPATH . $thumbnail_path; $thumbnail_image = '' . $video_id . '.jpg'; if (file_exists($upload_path . $thumbnail_image)) { $thumb_final = ' '; $thumb_final; } else { return macscr_create_thumb($video_id); } } function macscr_video_id($leftdelim, $rightdelim, $content) { $begin = strpos($content, $leftdelim); $end = strpos($content, $rightdelim, $begin); if ($begin !== false && $end !== false) { // numbers may be wrong, change them if you get wrong URL. $video_id = substr($content, $begin + 15, $end - $begin - 15); return $video_id; } } function macscr_add_thumbnail($content) { $leftdelim =''; $rightdelim = ''; $video_id = macscr_video_id($leftdelim, $rightdelim, $content); global $mytube_thumb; $mytube_thumb = "test"; return str_replace($leftdelim.$video_id.$rightdelim, '', $content); } add_filter('the_excerpt', 'macscr_add_thumbnail', $priority = '1'); ?>