Don't run an expensive query to fetch image IDs
Merge pull request #6 from borkweb/6041-slow-queries

Don't run an expensive query to fetch image IDs