is_type('variable')) { foreach ($product->get_available_variations() as $v) { if (!empty($v['image']['src'])) { $swap_url = $v['image']['src']; break; } } } if (!$swap_url) { $gallery = $product->get_gallery_image_ids(); if (!empty($gallery)) { $swap_url = wp_get_attachment_image_url($gallery[0], 'woocommerce_thumbnail'); } } if ($swap_url) { $html = preg_replace('/