How to dynamically chose DockerSpawner image based on user and container name in jupyterhub_config?

Hello,
I am trying to set up JuptyerHub using DockerSpawner as my spawner class. To specify the image to use, I would like to do it in function of of the username of the user trying to spawn the image, as well as the container name (e.g. use the image f’base-{username}-{container_name}’). I don’t think I am able to do this with the more static

c.DockerSpawner.image = ...

formulation, as I don’t have access to either of those variables. The closest I’ve came to my desired outcome is using the allowed_images attribute of DockerSpawner in the following manner:

def allowed_images_filter(spawner):
    username = spawner.user.name
    container_name = spawner.container_name
    image = f'base-{username}-{container_name}'
    return {
       '': image,
       image: image,
   }
c.DockerSpawner.allowed_images = allowed_images_filter

However, this forces the user to chose an image when spinning up a server. Ideally, I would like this to happen automatically. I tried returning the dictionary without the empty-string entry, but then I get an error that the image name is not in the allowed images.

Thank you in advance.