Show only posts with images and a fixed amount of posts

I haven’t tried it, but I think that one proper solution could be to write a simple function that runs after the post is published (on save) and checks wether this post has images inside or not.If it has maybe is good to update a custom field in the post that will be a boolean and will check if it this post has images or not.This way you can do a WP Query afterwards and get the posts with images using a meta_key query.