Improve selection handling when there are images