Fix image selection logic