Better handling of image preview