Getting the Vimeo video thumb

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Getting the Vimeo video thumb

Post 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.
Jean le Chauve

Re: Getting the Vimeo video thumb

Post 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.
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: Getting the Vimeo video thumb

Post 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
Do you like your open source cms? Buy from the CMSMS partners || Donate
User avatar
manuel
Power Poster
Power Poster
Posts: 353
Joined: Fri Nov 30, 2007 9:15 am

Re: Getting the Vimeo video thumb

Post 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
Do you like your open source cms? Buy from the CMSMS partners || Donate
Post Reply

Return to “Tips and Tricks”