fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Desiree Cole

https://capecodtowelco.com/product-category/towels/

The swatches are showing on products in the SHOP page, but some of them do nothing when clicked on. The image does not change.

Salute to Cape Cod swatches are not changing the main image when clicked on.

Lighthouses of CC & Island Martha’s Vineyard swatches are working.

I cannot figure out why some product swatches are working and some are not.

Hakik Zaman

Hi Desiree,

Thanks for reaching out to us.

I have added a snippet inside your current child theme’s functions.php file-

/**
* Remove extra srcset from images.
*/
add_filter( 'wp_calculate_image_srcset_meta', '__return_null' );

Please check now and let me know whether it resolves your issue or not.

Note: Please flush all the caches (browser cache, wp-engine cache, and server-side cache) before checking your site.

Hope to hear from you soon.

Thank You

Desiree Cole

Yes, the swatches are all working now.

 

Why did this code need to be added? The swatches were working up until not long ago.

Hakik Zaman

Hi Desiree,

One of your plugins or the theme is adding “srcset” attribute with the “img” tag.

Then displaying images based on the “srcset” attribute value.

That code is just removing the “srcset” to work with the default “src“.

I hope this will clear up your confusion. Hope to hear from you soon.

Thank You

Desiree Cole

Thanks for the clarification.

Another couple of questions:

Can we remove swatches from related products?

Does your plugin work well with the Image Swap for WooCommerce plugin by IconicWP?

Hakik Zaman

Hi Desiree,

Can we remove swatches from related products?

Please add the following CSS at Appearance > Customize > Additional CSS

.related.products .wvs-archive-variations-wrapper {
display: none;
}

Does your plugin work well with the Image Swap for WooCommerce plugin by IconicWP?

It will not work by default. Perhaps you have to change the image wrapper to make it work with the Image Swap plugin.

Thank You