Yes it is possible. I believe it is better if you put it in a conditional statement
- Check for featured image easy;
- Check for attached file with an image mime type using this and this;
- Check for any
<img>
tag in the post content (detail); - If there is no image at all, then use a default image
Hope this help