Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use Advanced Custom Fields to show Vimeo videoes on a site I am creating for a client - The client pastes the vimeo ID (the last letters in the url) in a field, and the video is shown. But I would also like to show thumbnail of the video, I am using the following (not working code) for this:

<?php
$imgid = the_field('video_link');
$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$imgid.php"));
echo $hash[0]['thumbnail_medium'];  
?>

This code only shows the video-ID on the page. But if I, instead for "the_field('video_link')" writes the video-ID in the code - the thumbnail URL is displayed. Does anyone know what I am doing wrong? :)

share|improve this question

migrated from stackoverflow.com Aug 8 '12 at 1:40

This question came from our site for professional and enthusiast programmers.

    
This doesn't really have anything to do with WordPress. Migrating to Stack Overflow where it will be more on-topic. –  EAMann Aug 7 '12 at 23:13
    
@EAMann I just flagged it to port it back to WPSE. This is about the WP Http API and belongs to us. –  kaiser Aug 8 '12 at 1:07
3  
file_get_contents() is a vanilla PHP function ... this is using a regular document from a third-party API. The question has absolutely nothing to do with WordPress or the WP_Http API. –  EAMann Aug 8 '12 at 2:39
    
Dupe that was closed: wordpress.stackexchange.com/questions/61163/vimeo-thumbnails –  songdogtech Aug 8 '12 at 4:08
add comment

1 Answer

up vote 3 down vote accepted

Maybe this can help

$videoID = the_field('video_link');
$jsonurl = 'http://vimeo.com/api/v2/video/'.$videoID.'.json';
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json,true);
echo '<img src="'. $json_output[0]['thumbnail_large'] .'" />';

It's the same call using json method

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.