Automattic\WooCommerce\Blocks\BlockTypes
ProductGalleryLargeImage::get_main_images_html
Get the main images html code. The first element of the array contains the HTML of the first image that is visible, the second element contains the HTML of the other images that are hidden.
Method of the class: ProductGalleryLargeImage{}
No Hooks.
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_main_images_html( $context, $product, $inner_block );
- $context(array) (required)
- The block context.
- $product(WC_Product) (required)
- The product object.
- $inner_block(WP_Block) (required)
- The inner block object.
ProductGalleryLargeImage::get_main_images_html() ProductGalleryLargeImage::get main images html code WC 10.3.6
<?php
private function get_main_images_html( $context, $product, $inner_block ) {
$image_data = ProductGalleryUtils::get_product_gallery_image_data( $product, 'woocommerce_single' );
ob_start();
?>
<ul
class="wc-block-product-gallery-large-image__container"
data-wp-interactive="woocommerce/product-gallery"
data-wp-on--keydown="actions.onSelectedLargeImageKeyDown"
aria-label="<?php esc_attr_e( 'Product gallery', 'woocommerce' ); ?>"
tabindex="0"
aria-roledescription="carousel"
>
<?php foreach ( $image_data as $index => $image ) : ?>
<li
class="wc-block-product-gallery-large-image__wrapper"
>
<?php
$image_html = (
new WP_Block(
$inner_block->parsed_block,
array_merge( $context, array( 'imageId' => $image['id'] ) )
)
)->render( array( 'dynamic' => true ) );
echo $this->update_single_image( $image_html, $context, $index ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
</li>
<?php endforeach; ?>
</ul>
<?php
$template = ob_get_clean();
return wp_interactivity_process_directives( $template );
}