Fix loop of image IDs