In your function you get the value of the field which is stored as an ID. You can either do it with ACF using $image = get_field('image_field', $post_id, false); which will return the ID value or you can use $image = get_post_meta($post_id, '', true);
then you do
$image = intval($image); // make sure it's an int
But this won’t be retroactive, you’d need to update every post.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users