Wocommerce lightbox broken once tempera activated

  • Author
    Posts
  • #31909
    Vinay

    Hi,

    I have a shop setup using wocommerce variable product and when I loaded tempera and tempeara-wocommerce child theme, lightbox functionality is broken. I am using ‘Featured Image’ only and NOT using product images. so I got only one image for each product and once I click on that image, normally it opens up in new big window, it works with default theme 2015 but once I load tempera it stoped.

    Versions used :
    Wordpress – 4.2.2
    WooCommerce – 2.3.9
    Tempera – 1.2.8
    Tempera WooCommerceVersion: 0.1-20140212

    I noticed it’s adding extra anchor tag

    ********************************** Broken sample code ********************

    <div class="images">
     
    
     
    
    20141225-Albury-3  =======================>  I guess this anchor tag is culprit, but don't know how this is getting formed.
    
    </div>
     
    <div class="summary entry-summary">`====> end to identify in code....

    ********************************** Broken sample ends ********************

    ********************************** Working sample ********************

    <div class="images">
    <a href="http://localhost  /wordpress /wp-content/uploads/2015/05 /20141225- Albury-3.jpg" itemprop="image" class="woocommerce-main-image zoom" title="" data-rel="prettyPhoto"><img width="600" height="200" src="http://localhost/wordpress/ wp-content/uploads/2015/05/20141225- Albury-3-600x20.jpg" class="attachment-shop_single wp-post-image" alt="20141225-Albury-3" title="20141225-Albury-3" /></a>
    </div>
    <div class="summary entry-summary">

    ********************************** Working sample ends ********************

    Please help to point out how can I fix it?

    • This topic was modified 8 years ago by Zed. Reason: cleaned up code markup
    #31910
    Vinay

    sorry, here is the broken code- I have added space manually in URLs so as not to show image icon…

    <div class="images">
     
    
     
    
    20141225-Albury-3  =======================>  I guess this anchor tag is culprit, but don't know how this is getting formed.
    
    </div>
    
    #31978
    Zed
    Cryout Creations mastermind

    Uncheck the Link the thumbnail to the post option in theme settings (under Featured Image Settings) and see if that solves this.


    If you like our creations, help us share by rating them on WordPress.org.
    Please check the available documentation and search the forums before starting a topic.
    #32142
    Vinay

    Spot on!
    Thanks a lot ZED! YES it fixed the issue, and I found another way, before your reply, thought to share….

    I was able to fix the issue by adding below code to function.php of tempera theme

    ************************ code starts **************************************

    function fix_woocommerce_single_product_image_html($html) {
        $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
        preg_match_all("/$regexp/siU", $html, $matches, PREG_SET_ORDER);
    
        $image_link = $matches[0][2];
    
        $image_title = esc_attr( get_the_title( get_post_thumbnail_id() ) );
        $image_caption = get_post( get_post_thumbnail_id() )->post_excerpt;
    
        $image = '<img src="' . $image_link . '" alt="' . $image_caption . '" /></img>';
    
        $str = '<a href=" ' . $image_link . ' " title="' . $image_caption . '">' . $image . '</a>';
    
        return $str;
    }
    
    add_filter('woocommerce_single_product_image_html', 'fix_woocommerce_single_product_image_html', 99, 1); // single image
    add_filter('woocommerce_single_product_image_thumbnail_html', 'fix_woocommerce_single_product_image_html', 99, 1); // thumbnails
    

    ************************ code ends **************************************

    I hope it will help to someone who is facing similar issue.

    • This reply was modified 8 years ago by Zed. Reason: corrected code display
    #33995
    luis

    hi i got the same problem, for some reason the lightbox on woocommerce’s images saying “see more” doesn’t work as used to be, i also activated child theme i don’t know what happened, i tried uncheck the link the thumbnail and just resolved the rollover of the product title but not the lightbox, tried this code of Vinay but there’s some mistake because give me an error, please i expect your help regards

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Wocommerce lightbox broken once tempera activated’ is closed to new replies.