Home › Forums › ACF PRO › Oembed and repeater › Reply To: Oembed and repeater
The joys of code!
The youtube aspect worked great for me, it was just the vimeo side. I solved this by replacing the get_vimeo_uri function with the code example provided by vimeo here – https://github.com/vimeo/vimeo-oembed-examples/blob/master/oembed/php-example.php
I had to make a small tweak to pass the full url rather than just the id.
function get_vimeo_thumbnail_uri( $clip_id ) {
$clip_id = 'https://vimeo.com/'.$clip_id;
$oembed_endpoint = 'http://vimeo.com/api/oembed';
// Grab the video url from the url, or use default
$video_url = ($_GET['url']) ? $_GET['url'] : $clip_id;
// Create the URLs
$json_url = $oembed_endpoint . '.json?url=' . rawurlencode($video_url) . '&width=640';
$xml_url = $oembed_endpoint . '.xml?url=' . rawurlencode($video_url) . '&width=640';
// Curl helper function
function curl_get($url) {
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$return = curl_exec($curl);
curl_close($curl);
return $return;
}
// Load in the oEmbed XML
$oembed = simplexml_load_string(curl_get($xml_url));
/*
An alternate approach would be to load JSON,
then use json_decode() to turn it into an array.
*/
return $oembed->thumbnail_url;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.