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( $media_items );
- $media_items(array) (required)
- An array of all media items of the product.
ProductGallery::render_dialog() ProductGallery::render dialog code WC 11.2.1
<?php
protected function render_dialog( $media_items ) {
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 foreach ( $media_items as $index => $media ) : ?>
<?php if ( 'video' === ( $media['media_type'] ?? '' ) ) : ?>
<?php echo $this->get_dialog_video_html( $media ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php else : ?>
<img
data-image-id="<?php echo esc_attr( $media['id'] ); ?>"
data-wp-watch="callbacks.toggleImageVisibility"
src="<?php echo esc_url( $media['src'] ); ?>"
srcset="<?php echo esc_attr( $media['srcset'] ); ?>"
sizes="<?php echo esc_attr( $media['sizes'] ); ?>"
decoding="async"
alt="<?php echo esc_attr( $media['alt'] ); ?>" />
<?php endif; ?>
<?php endforeach; ?>
</div>
</dialog>
<?php
return ob_get_clean();
}