Repeat escaped foreach until count is met

The PHP spread operator requires PHP 7.4.

You can replace it with array_merge if PHP 7.4 is not an option for you:

- array_push($images, ...array_slice($images, 0, 10 - count($images)));
+ $images = array_merge($images, array_slice($images, 0, 10 - count($images)));