Support

Account

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