New Landing How can we help? Themeforest Theme Support Neighborhood Undefined variable: image_html

Viewing 6 posts - 1 through 6 (of 6 total)
  • #306512
    vremeni4
    Member
    Post count: 2

    Hi,

    If I enable debugging in WordPress I constantly get following error messages
    —–
    09-Dec-2016 13:25:44 UTC] PHP Notice: Undefined variable: image_html in /websites/123reg/LinuxPackage22/fl/ig/ht/flighttraininglondon.co.uk/public_html/webshop/wp-content/themes/neighborhood/woocommerce/single-product/product-image.php on line 84
    [09-Dec-2016 13:25:44 UTC] PHP Notice: Undefined variable: image_html in /websites/123reg/LinuxPackage22/fl/ig/ht/flighttraininglondon.co.uk/public_html/webshop/wp-content/themes/neighborhood/woocommerce/single-product/product-image.php on line 138
    —-
    If I look at the code in product-image.php
    then the variable image_html is indeed set after it was used.
    —snip
    if ( $product_image_srcset ) {
    $image = get_the_post_thumbnail( $post->ID, apply_filters( ‘single_product_large_thumbnail_size’, ‘shop_single’ ), array(
    ‘title’ => get_the_title( get_post_thumbnail_id() )
    ) );
    echo apply_filters( ‘woocommerce_single_product_image_html’, sprintf( ‘<li itemprop=”image” data-thumb=”%s”>%s%s<i class=”fa-search-plus”></i>‘, $thumb_image, $image_html, $caption_html, $image_link, $image_caption, $image_title, $image_alt ), $post->ID );
    } else {
    $image = aq_resize( $image_link, 800, NULL, true, false);
    if ($image) {
    $image_html = ‘'.$image_alt.'‘;

    echo apply_filters( ‘woocommerce_single_product_image_html’, sprintf( ‘<li itemprop=”image” data-thumb=”%s”>%s%s<i class=”fa-search-plus”></i>‘, $thumb_image, $image_html, $caption_html, $image_link, $image_caption, $image_title, $image_alt ), $post->ID );
    }
    }
    –snip
    What is the best approach to fix this bug.

    Thanks

    Kind regards,
    Ivan

    #306624
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Can you tell us what is the PHP version of that server?
    Thanks

    -Rui

    #306680
    vremeni4
    Member
    Post count: 2

    Hi,

    the PHP version is 5.6.28.
    Anyhow the variable Image_Html is defined after it was used, so the problem will be the same regardless of the PHP version.

    Thanks.

    Kind regards,
    Ivan

    #306692
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Thanks will try to replicate and get back to you, it seems to just miss the initialization of the var before it’s first use. That warning should go away when you turn off the debug mode.

    -Rui

    #307373
    vremeni4
    Member
    Post count: 2

    Hi,

    Any update on this ?
    I need to have Debug mode enabled because of some other issues. In other words this work around will not work for me.
    If debug Mode is enabled then the images do not appear on the Single Product page.
    The warning/ error message appears, and then images are not shown. As you can imagine this is a problem.

    If you think that the bug will be fixed just by initializing the variable Image_html, I can do that myself, but this would be just patching.
    Personally I would prefer a better structure of the code, where the variables are read an populated in the right order.

    Thanks for your help.
    Kind regards,
    Ivan

    #307421
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Apologize for the delay, can you replace the file product-image.php by this one attached?
    https://www.dropbox.com/s/qncymt6remgimkn/product-image.php?dl=0

    Let me know if the warning error stops.

    -Rui

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

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register