A PHP Function To Get Vimeo Video Thumbnails Easily

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.

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;
}
}

Also read...

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.