The Genesis theme framework includes a useful function for retrieving a post image:
genesis_get_image(). It uses the featured image, but if no featured image is specified it will use the first image uploaded to the post.
Yoast SEO only looks at the featured image for a post. If there is no featured image, no image is attached to the article’s schema and you’ll get a schema error (screenshot).
The following code will only run on singular content (posts, pages…) that do not have a featured image. It sees if
genesis_get_image() can find an image in the post, and if so it sets that as the image in Yoast SEO’s schema.