1

I would like to add a custom CSS when displaying product images. E.g. when calling the woocommerce_get_product_thumbnail function.

I've tried solutions like this: Add CSS class to every image but they don't work. The class only gets added to images that are not related to products.

1
  • Please show your code. Commented Nov 16, 2018 at 4:00

1 Answer 1

1

If it's still relevant, you can add a class to the product thumbnail the following way.

function loop_product_custom_thumbnail() { echo the_post_thumbnail('thumbnail', array('class' => 'your-class-name')); } remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10); add_action( 'woocommerce_before_shop_loop_item_title', 'loop_product_custom_thumbnail', 10 ); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.