Added the code to check if there is no featured image in the post to retrieve the first image attached