How to add classes to Woocommerce product img


<img src="http://localhost/wp-content/uploads/2022/02/long-sleeve-tee-2-300x300.jpg" class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail" alt="" loading="lazy"   width="300" height="300">

I’ve searched everywhere I can think for class="attachment-woocommerce_thumbnail size-woocommerce_thumbnail" with no luck.

I tried adding the classes with Jquery.

'use strict';
( function( $ ) {

    <?php if (is_shop()):  ?>
    // Add classes to the img tag
    $('.attachment-woocommerce_thumbnail').addClass('w-full md:h-96 sm:h-auto object-cover');
    <?php else: ?>
    $('.attachment-woocommerce_thumbnail').addClass('w-full object-cover 2md:h-96');
    <?php endif ?>
} )(jQuery);

Which works at first, but I use a infinite scroll plugin someone else wrote, and it does not add the classes to the new images.

I was trying to add a tag for Woocommerce but was told by the tag that its off topic and go to I did that but they dont do devopler support. Proof

Tom J Nowell 10 months 2022-03-30T17:49:27-05:00 0 Answers 0 views 0

Leave an answer