@ChristineCooper this function is pretty simple: https://core.trac.wordpress.org/browser/tags/5.1.1/src/wp-includes/post.php#L5534
So... I would just debug it and check which part of it doesn't work.
If after this line: https://core.trac.wordpress.org/browser/tags/5.1.1/src/wp-includes/post.php#L5540 the $data contains proper values, then it's probably caused by "wp_get_attachment_metadata" filter. If it's incorrect already at this time, then you have to check earlier (in get_post_meta for example)