Automattic\WooCommerce\StoreApi\Schemas\V1
ProductSchema::get_images
Get list of product images.
Method of the class: ProductSchema{}
No Hooks.
Returns
Array.
Usage
// protected - for code of main (parent) or child class $result = $this->get_images( $product );
- $product(WC_Product) (required)
- Product instance.
ProductSchema::get_images() ProductSchema::get images code WC 10.9.1
protected function get_images( \WC_Product $product ) {
$attachment_ids = array_filter( array_merge( [ $product->get_image_id() ], $product->get_gallery_image_ids() ) );
if ( ! empty( $attachment_ids ) ) {
// Prime caches to reduce future queries.
_prime_post_caches( $attachment_ids );
}
return array_values( array_filter( array_map( [ $this->image_attachment_schema, 'get_item_response' ], $attachment_ids ) ) );
}