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.

Метод класса: ProductGalleryLargeImage{}

Хуков нет.

Возвращает

Массив.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_main_images_html( $context, $product_id );
$context(массив) (обязательный)
The block context.
$product_id(int) (обязательный)
The product id.

Код ProductGalleryLargeImage::get_main_images_html() WC 9.6.2

private function get_main_images_html( $context, $product_id ) {
	$attributes = array(
		'class'                  => 'wc-block-woocommerce-product-gallery-large-image__image',
		'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';
	}

	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 );
}