Zend certified PHP/Magento developer

Magento 2.4.6: How to make auto select first child product of configurable product?

I am using version 2.4.6. I am trying to make auto select first child product from the configurable product in product detail page.

Because the main image of the configurable product will overlap with the image of the virtual product, I want to hide the main image of the configurable product and let the system automatically select the first virtual product.

If I add pictures to the configurable product, use the following code to solve the problem of repeated display of pictures, but this will cause many duplicate images to occupy server resources.

app/design/frontend/yourtheme/yourtheme/etc/view.xml

<vars module="Magento_ConfigurableProduct"> <var name="gallery_switch_strategy">prepend</var> </vars>

change into

<vars module="Magento_ConfigurableProduct"> <var name="gallery_switch_strategy">replace</var> </vars>

I don’t want to use this method to solve the problem.

Is this possible?