The solution still is the same, I've tested in magento 2.4.5:
Adding these lines of code to the theme view.xml file: < your theme dir>/etc/view.xml
<vars module="Magento_ConfigurableProduct">
<var name="gallery_switch_strategy">replace</var>
</vars>
your theme view.xml will be looks like this:
<?xml version="1.0"?>
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
<vars module="Magento_ConfigurableProduct">
<var name="gallery_switch_strategy">replace</var>
</vars>
</view>
You can read more here: https://github.com/magento/magento2/blob/2.4.5/app/code/Magento/ConfigurableProduct/README.md#configurable-variables-through-the-theme-viewxml