ACF

How to set Image Field as Featured Image

This feature is included in ACF Extended plugin

In order to automatically set an Image field as featured thumbnail for a post, we will have to use acf/update_value. Image fields create new attachments upon upload and store the attachment_id in the field value. This behavior is identical to the WordPress one.

add_filter('acf/update_value/name=my_image', 'acf_image_set_featured_image', 10, 3);
function acf_image_set_featured_image($value, $post_id, $field){
    
    if(empty($value) || empty(get_post_type($post_id)))
        return $value;
    
    update_post_meta($post_id, '_thumbnail_id', $value);
    
    return $value;
    
}

As J. Huebner suggested on the official ACF Forum, it’s also possible to directly set the field_name as the native WP custom field: _thumbnail_id. Less flexible but effective, as no filter is needed this case.

ACF Hooks

ACF Fields