To elaborate on Violacase answer.
The _thumbnail_id
is the meta_key which the thumbnail ID is being saved with in the wp_postmeta table in your database. It’s being used by default by WordPress.
And if you have the image output set to object you can just use $value->ID and you’re good to go!