get_image_id(); // Get Second Image in Gallery. if ( version_compare( OceanWP_WooCommerce_Config::get_wc_version(), '2.7', '>=' ) ) { $attachment_ids = $product->get_gallery_image_ids(); } else { $attachment_ids = $product->get_gallery_attachment_ids(); } $attachment_ids[] = $attachment; // Add featured image to the array. $secondary_img_id = ''; if ( ! empty( $attachment_ids ) ) { $attachment_ids = array_unique( $attachment_ids ); // remove duplicate images. if ( count( $attachment_ids ) > '1' ) { if ( $attachment_ids['0'] !== $attachment ) { $secondary_img_id = $attachment_ids['0']; } elseif ( $attachment_ids['1'] !== $attachment ) { $secondary_img_id = $attachment_ids['1']; } } } // Image args. $first_img = array( 'class' => 'woo-entry-image-main', 'alt' => get_the_title(), ); if ( oceanwp_get_schema_markup( 'image' ) ) { $first_img['itemprop'] = 'image'; } $second_img = array( 'class' => 'woo-entry-image-secondary', 'alt' => get_the_title(), ); if ( oceanwp_get_schema_markup( 'image' ) ) { $second_img['itemprop'] = 'image'; } // Return thumbnail. if ( $secondary_img_id ) : ?>