Home › Forums › Feedback › Auto Prefill Fields based on EXIF › Reply To: Auto Prefill Fields based on EXIF
This is actually what I’ve done so far, but it only works when afc/save_post triggers, and I’ve no live refresh of the fields either:
if (class_exists('acf')){
function taz_prefill_metadata($post_id) {
$fullImagePath = wp_get_attachment_url($post_id);
$metadata = exif_read_data($fullImagePath);
if ($metadata === false) {
exit;
} else {
$customFields = get_field_objects($post_id);
update_field($customFields['reference']['name'], (string)$metadata[FocalLength], $post_id);
}
}
}
add_action('acf/save_post', 'taz_prefill_metadata', 20); // run after ACF saves the $_POST['acf'] data
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.