I now realise that when you said 12 critical trials, you probably didn’t mean a consecutive block of 12 randomised trials. What you are trying to achieve sounds like a prospective memory task, though if so, I’m not sure why you would want the background task to be in a fixed order.
What I do for PM is preload the background and target trials into two lists and then have a trials loop which selects from the appropriate list each trial. One of my PM tasks, called PM Time, is in my Online Demos post.
However, you absolutely could just predefine your 12 target images in a shuffled list (targetfiles) and then have “critical_trial” in your spreadsheet when you want to show them
Use the following code in Begin Routine
thisImage = imgfile
if imgfile == 'critical_trial':
thisImage = targetfiles.pop()
then set your image as thisImage each repeat (making sure that the image component is below the code component).