Here i share code.
If you want this functionality you need to do custom jquery.
Check this code maybe it’s help to you
jQuery(document).ready(function($) {
// Map image URLs to their corresponding variation IDs
var imageVariationMap = {};
$('.variations_form').on('found_variation', function(event, variation) {
if (variation && variation.image && variation.image.src) {
imageVariationMap[variation.image.src] = variation.variation_id;
}
});
// Handle image click event
$('.woocommerce-product-gallery__image img').on('click', function() {
var clickedImageSrc = $(this).attr('src');
// Find the corresponding variation ID
var variationID = imageVariationMap[clickedImageSrc];
if (variationID) {
// Change the selected variation
$('input.variation_id').val(variationID).change();
// Trigger WooCommerce variation change events
$('.variations_form').trigger('check_variations');
$('.variations_form').trigger('woocommerce_variation_select_change');
$('.variations_form').trigger('woocommerce_update_variation_values');
}
});
});