Automattic\WooCommerce\Blocks\BlockTypes
ProductGallery::render_dialog
Return the dialog content.
Method of the class: ProductGallery{}
No Hooks.
Returns
String.
Usage
// protected - for code of main (parent) or child class $result = $this->render_dialog( $images );
- $images(array) (required)
- An array of all images of the product.
ProductGallery::render_dialog() ProductGallery::render dialog code WC 10.9.1
<?php
protected function render_dialog( $images ) {
$images_html = '';
foreach ( $images as $image ) {
$id = esc_attr( $image['id'] );
$src = esc_url( $image['src'] );
$srcset = esc_attr( $image['srcset'] );
$sizes = esc_attr( $image['sizes'] );
$alt = esc_attr( $image['alt'] );
$images_html .= "<img data-image-id='{$id}' data-wp-watch='callbacks.toggleImageVisibility' src='{$src}' srcset='{$srcset}' sizes='{$sizes}' decoding='async' alt='{$alt}' />";
}
ob_start();
?>
<dialog
data-wp-bind--open="context.isDialogOpen"
data-wp-bind--inert="!context.isDialogOpen"
data-wp-on--close="actions.closeDialog"
data-wp-on--keydown="actions.onDialogKeyDown"
data-wp-watch="callbacks.dialogStateChange"
class="wc-block-product-gallery-dialog"
role="dialog"
aria-modal="true"
aria-label="Product Gallery">
<div class="wc-block-product-gallery-dialog__header">
<button class="wc-block-product-gallery-dialog__close-button" data-wp-on--click="actions.closeDialog" aria-label="<?php echo esc_attr__( 'Close dialog', 'woocommerce' ); ?>">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
<path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path>
</svg>
</button>
</div>
<div class="wc-block-product-gallery-dialog__content">
<?php // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Attribute values are escaped above when building $images_html. ?>
<?php echo $images_html; ?>
</div>
</dialog>
<?php
return ob_get_clean();
}