Home › Forums › Backend Issues (wp-admin) › Fill field with remote data? › Reply To: Fill field with remote data?
Oh, also just going to post my code in case it’s helpful or if someone wants to yell at me for being wrong:
// Fetch vimeo thumbnail on save - takes video ID as input
function rf_acf_update_vimeo_thumb( $value, $post_id, $field ) {
// only set a new value if the field is empty
if ( $value == '') {
// get video here
$vimeo_video_id = get_field('vimeo_video_id');
// fetch thumb url(s)
$vimeo_meta = file_get_contents("https://vimeo.com/api/v2/video/$vimeo_video_id.json");
$vimeo_meta = json_decode($vimeo_meta);
$vimeo_thumb = $vimeo_meta[0]->thumbnail_large;
// set value
$value = $vimeo_thumb;
return $value;
} else {
return $value;
}
}
add_filter('acf/update_value/name=thumbnail_url', 'rf_acf_update_vimeo_thumb', 10, 3);
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.