Automattic\WooCommerce\Blocks\BlockTypes
ProductGallery::get_product_image_attributes
Find the Product Image block attributes used by the gallery.
Method of the class: ProductGallery{}
No Hooks.
Returns
array|null.
Usage
// private - for code of main (parent) class only $result = $this->get_product_image_attributes( $inner_blocks );
- $inner_blocks(iterable<\WP_Block>) (required)
- Inner blocks to search.
ProductGallery::get_product_image_attributes() ProductGallery::get product image attributes code WC 11.3.0
private function get_product_image_attributes( $inner_blocks ) {
foreach ( $inner_blocks as $inner_block ) {
if ( 'woocommerce/product-image' === $inner_block->name ) {
return $inner_block->parsed_block['attrs'] ?? array();
}
$found_attributes = $this->get_product_image_attributes( $inner_block->inner_blocks );
if ( null !== $found_attributes ) {
return $found_attributes;
}
}
return null;
}