Recently on a client WordPress website I needed a simple way to get Vimeo video thumbnails via video ID. I couldn’t find anything readily available or even a snippet, so I created a function that helps out and even has a return or echo option as well.
[code]function get_vimeo_thumb($videoid, $size = “large”, $return = false)
{
$imgid = $videoid;
$hash = unserialize(file_get_contents(“http://vimeo.com/api/v2/video/$imgid.php”));
$the_thumb = ”;
switch ($size) {
case ‘small’:
$the_thumb = $hash[0][‘thumbnail_small’];
break;
case ‘medium’:
$the_thumb = $hash[0][‘thumbnail_medium’];
break;
case ‘large’:
$the_thumb = $hash[0][‘thumbnail_large’];
break;
}
if (!$return)
{
echo $the_thumb;
}
else
{
return $the_thumb;
}
}[/code]