Load dynamic background

I’m loading a json file in the preload function and then would like to load a background based on the contents of that json file. Is this all doable inside the preload function?

You can add a callback within preload(). But it won’t run when preload() is run, only afterwards.

I spent the last 6-12 months creating 50 background images so I sorta need to re-learn Phaser callbacks, etc. These images are about 20MB each so I most likely need to make the file sizes smaller. For now, my plan is to preload all or most of these images and then use this to display the image I want:

this.make.image(config1).setOrigin(0);

With ‘this.add.image’ I can’t find a way to use variables but with ‘this.make.image’ I can use variables. Hope I made sense. I know this is probably not the most elegant way to approach this but the other possibility is to create 50 different scene files(?) - each with a unique background image. Right now, I have one game.js file which is about 875kb. Storing 50 files of this size is probably not best practice.