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.
Метод класса: ProductGalleryLargeImage{}
Хуков нет.
Возвращает
Массив.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_main_images_html( $context, $product, $inner_block );
- $context(массив) (обязательный)
- The block context.
- $product(WC_Product) (обязательный)
- The product object.
- $inner_block(WP_Block) (обязательный)
- The inner block object.
Код ProductGalleryLargeImage::get_main_images_html() ProductGalleryLargeImage::get main images html WC 10.4.3
<?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 );
}