Page 1 of 1

Getting the Vimeo video thumb

Posted: Mon Jul 30, 2012 2:54 am
by carasmo
UDT

Code: Select all

/**
 * Gets a vimeo thumbnail url
 * @param mixed $id A vimeo id (ie. 1185346)
 * @return thumbnail's url
 * http://stackoverflow.com/a/10503411
 * usage: {vimeothumb id='1185346'}
*/


$id = $params['id'];
$data = file_get_contents("http://vimeo.com/api/v2/video/$id.json");
$data = json_decode($data);
return $data[0]->thumbnail_large;

Code: Select all

usage: {vimeothumb id='1185346'}
Makes the full path to the video, put in an image tag. I'm using this to just input an id in a custom field in the CGBlog so that it gets the thumb for the summary page and the video for the detail page, see it at my blog dropsoul(dot)com/blog.html the post titled "testing thumb UDT for vimeo" which is on the first page for now.

Re: Getting the Vimeo video thumb

Posted: Thu Oct 18, 2012 1:13 pm
by Jean le Chauve
Thanks :)
HostedVideoAlbums could not display the thumbnail of vimeo, so I replaced the code with yours and everything works perfectly now.

Re: Getting the Vimeo video thumb

Posted: Tue Nov 13, 2012 2:43 pm
by manuel
Dear Carasmo,

Thanks for sharing!
(I have a site coming up where i'll be publishing a lot of video's in one big list using only their thumbnails so this will definitely get used there!)

Greetings,
Manuel

Re: Getting the Vimeo video thumb

Posted: Wed Jul 17, 2013 8:55 pm
by manuel
If you want to use this with "private" video's you can't use the "Simple API" because that one is for public data only.

A small change to file_get_contents & $vimeothumb does the trick:
(the bottom part is different as well but that's only to get the URL in a var instead of using return)

Code: Select all

$id = $params['id'];
$data = file_get_contents("http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/$id");
$data = json_decode($data);
$vimeothumb = $data->thumbnail_url;

$smarty = cmsms()->GetSmarty();
$smarty->assign('vimeothumb', $vimeothumb);
Greetings,
Manuel