I'm using the following code to grab the image of every variation for a particular product:
$product = new WC_Product_Variable( $product_id );
$variations = $product->get_available_variations();
foreach ( $variations as $variation ) {
echo "<img src=" . $variation['image']['url'] .">";
}
This returns the full size image.
Can anyone tell me how I would modify this to return the 'thumbnail' URL? (or any other size)
I'm sure it's a fairly simple change but I just can't figure it out.
If you know the product variation ID, you can do
See related docs found at the Woocommerce reference for WC_product_variation class and the WC_Product class. The function get_image() is actually inherited from WC_Product, but you can use it in either class.
Use thumb_src instead of url.