I am using this function to get the featured images:
I think this is the easiest solution and the updated one: