');
$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 = '
';
} else {
$thumb_final = '
';
}
}
return $thumb_final;
}
function macscr_video_id($content)
{
$begin = strpos($content, '');
$end = strpos($content, '', $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);
}
if (!$video_id) {
return false;
} else {
return macscr_get_thumbnail($video_id);
}
}
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 = '
';
return $thumb_final;
} else {
return macscr_create_thumb($video_id);
}
}
function macscr_add_thumbnail($content)
{
global $mytube_thumb;
$mytube_thumb = macscr_video_id($content);
return $content;
}
add_filter('the_content', 'macscr_add_thumbnail', $priority = '1');
?>