Automattic\WooCommerce\Blocks\BlockTypes

ProductGalleryLargeImage::get_main_images_html()privateWC 1.0

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.

Return

Array.

Usage

// private - for code of main (parent) class only
$result = $this->get_main_images_html( $context, $product_id );
$context(array) (required)
The block context.
$product_id(int) (required)
The product id.

ProductGalleryLargeImage::get_main_images_html() code WC 9.3.3

private function get_main_images_html( $context, $product_id ) {
	$attributes = array(
		'class'                  => 'wc-block-woocommerce-product-gallery-large-image__image',
		'data-wc-bind--hidden'   => '!state.isSelected',
		'data-wc-watch'          => 'callbacks.scrollInto',
		'data-wc-bind--tabindex' => 'state.thumbnailTabIndex',
		'data-wc-on--keydown'    => 'actions.onSelectedLargeImageKeyDown',
		'data-wc-class--wc-block-woocommerce-product-gallery-large-image__image--active-image-slide' => 'state.isSelected',
	);

	if ( $context['fullScreenOnClick'] ) {
		$attributes['class'] .= ' wc-block-woocommerce-product-gallery-large-image__image--full-screen-on-click wc-block-product-gallery-dialog-on-click';
	}

	if ( $context['hoverZoom'] ) {
		$attributes['class']              .= ' wc-block-woocommerce-product-gallery-large-image__image--hoverZoom';
		$attributes['data-wc-bind--style'] = 'state.styles';
	}

	$main_images = ProductGalleryUtils::get_product_gallery_images(
		$product_id,
		'full',
		$attributes,
		'wc-block-product-gallery-large-image__image-element',
		$context['cropImages']
	);

	$main_image_with_wrapper = array_map(
		function ( $main_image_element ) {
			return "<li class='wc-block-product-gallery-large-image__wrapper'>" . $main_image_element . '</li>';
		},
		$main_images
	);

	$visible_main_image = array_shift( $main_images );
	return array( $visible_main_image, $main_image_with_wrapper );
}