I’ve got code in my functions.php which parses the WP uploads folder and lists all images it finds there. Is it possible to place a filter here that would exclude any image that is already “attached” to a post?
eg: “List all images in folder “uploads” where image is not found in (attached images)”
Under Media / Edit, there’s a means to list them, so I suggest you reuse the existing API.
Else, a general method, which works anywhere, is to run a db query with a left join: