Lightbox is not working on translated page
-
Hi, the lightbox function is not working on the translated page. It is working only when I press on additional images, if you press on the main image it is not working.
This is how the product images are posted in my theme.<div class="images"> <?php if ( has_post_thumbnail() ) { $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); $full_size_image = wp_get_attachment_image_src( $post_thumbnail_id, 'full' ); $image_title = get_post_field( 'post_excerpt', $post_thumbnail_id ); $attributes = array( 'title' => $image_title, 'data-src' => $full_size_image[0], 'data-large_image' => $full_size_image[0], 'data-large_image_width' => $full_size_image[1], 'data-large_image_height' => $full_size_image[2], ); $html = '<div data-thumb="' . get_the_post_thumbnail_url( $post->ID, 'shop_thumbnail' ) . '" class="woocommerce-main-image woocommerce-product-gallery__image"><a href="' . esc_html__( $full_size_image[0]). '"target="_blank">'; $html .= get_the_post_thumbnail( $post->ID, 'shop_single', $attributes ); $html .= '</a></div>'; } else { $html = '<div class="woocommerce-product-gallery__image--placeholder">'; $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'freestyle' ) ); $html .= '</div>'; } echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, get_post_thumbnail_id( $post->ID ) ); // print out of sale on image if($product->is_in_stock()){ add_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10); remove_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20); do_action( 'woocommerce_before_single_product_summary' ); } ?> <?php do_action( 'woocommerce_product_thumbnails' ); ?> </div>
<div class="images"> <?php if ( has_post_thumbnail() ) { $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); $full_size_image = wp_get_attachment_image_src( $post_thumbnail_id, 'full' ); $image_title = get_post_field( 'post_excerpt', $post_thumbnail_id ); $attributes = array( 'title' => $image_title, 'data-src' => $full_size_image[0], 'data-large_image' => $full_size_image[0], 'data-large_image_width' => $full_size_image[1], 'data-large_image_height' => $full_size_image[2], ); $html = '<div data-thumb="' . get_the_post_thumbnail_url( $post->ID, 'shop_thumbnail' ) . '" class="woocommerce-main-image woocommerce-product-gallery__image"><a href="' . esc_html__( $full_size_image[0]). '"target="_blank">'; $html .= get_the_post_thumbnail( $post->ID, 'shop_single', $attributes ); $html .= '</a></div>'; } else { $html = '<div class="woocommerce-product-gallery__image--placeholder">'; $html .= sprintf( '<img src="%s" alt="%s" class="wp-post-image" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'freestyle' ) ); $html .= '</div>'; } echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, get_post_thumbnail_id( $post->ID ) ); // print out of sale on image if($product->is_in_stock()){ add_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10); remove_action('woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20); do_action( 'woocommerce_before_single_product_summary' ); } ?> <?php do_action( 'woocommerce_product_thumbnails' ); ?> </div>
The main part of this code is this line.
$html = '<div data-thumb="' . get_the_post_thumbnail_url( $post->ID, 'shop_thumbnail' ) . '" class="woocommerce-main-image woocommerce-product-gallery__image"><a href="' . esc_html__( $full_size_image[0]). '"target="_blank">';
Maybe you have an idea how can I make it work.
I tried all the troubleshooting options. Did not helped.
Thanks in advance for any ideas.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Lightbox is not working on translated page’ is closed to new replies.