= isset( $attributes['mode'] ) && 'full' !== $attributes['mode'] ? $this->render_dialog() : ''; $post_id = $block->context['postId'] ?? ''; $product = wc_get_product( $post_id ); $product_gallery_first_image = ProductGalleryUtils::get_product_gallery_image_ids( $product, 1 ); $product_gallery_first_image_id = reset( $product_gallery_first_image ); $product_id = strval( $product->get_id() ); $html = $this->inject_dialog( $content, $dialog ); $p = new \WP_HTML_Tag_Processor( $html ); if ( $p->next_tag() ) { $p->set_attribute( 'data-wc-interactive', wp_json_encode( array( 'namespace' => 'woocommerce/product-gallery' ) ) ); $p->set_attribute( 'data-wc-context', wp_json_encode( array( 'selectedImage' => $product_gallery_first_image_id, 'firstMainImageId' => $product_gallery_first_image_id, 'isDialogOpen' => false, 'visibleImagesIds' => ProductGalleryUtils::get_product_gallery_image_ids( $product, $number_of_thumbnails, true ), 'dialogVisibleImagesIds' => ProductGalleryUtils::get_product_gallery_image_ids( $product, null, false ), 'mouseIsOverPreviousOrNextButton' => false, 'productId' => $product_id, 'elementThatTriggeredDialogOpening' => null, ) ) ); if ( $product->is_type( 'variable' ) ) { $p->set_attribute( 'data-wc-init--watch-changes-on-add-to-cart-form', 'callbacks.watchForChangesOnAddToCartForm' ); } $p->add_class( $classname ); $p->add_class( $classname_single_image ); $html = $p->get_updated_html(); } return $html; } }