Finally got that damn query to work for selecting images