Support » Plugin: WooCommerce » Remove link on featured image – since 3.0.0

  • Hello,

    I was using this function, to remove main product image link in single product view:

    	function custom_unlink_single_product_image( $html, $post_id ) {
    		return get_the_post_thumbnail( $post_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
    	}
    	add_filter('woocommerce_single_product_image_html', 'custom_unlink_single_product_image', 10, 2);
    

    Because of 3.0.0 changes, function is not working. How can I get it work again?

    Thanks you

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    In 3.0.0 new galleries, the image does not ‘link’. It zooms and only enlarges when you click the magnifier.

    Thus this snippet does not translate 1:1 to the gallery in 3.0.

    Thread Starter gore.m

    (@gorem)

    Im little confused.
    I didnt add new gallery features support to my theme (I dont want them) and Im using only main product image.
    So… there should not be hover link on main product image as default? I have it there :-/

    Thanks you

    The filter is now ‘woocommerce_single_product_image_thumbnail_html’ instead of ‘woocommerce_single_product_image_html’

    EDIT: And it passes the attachment id instead of the post id as the second argument. https://github.com/woocommerce/woocommerce/blob/master/templates/single-product/product-image.php#L58

    Thread Starter gore.m

    (@gorem)

    I done first part:

    	function custom_unlink_single_product_image( $html, $post_id ) {
    		return get_the_post_thumbnail( $post_id, apply_filters( 'woocommerce_single_product_image_thumbnail_html', 'shop_single' ) );
    	}
    	add_filter('woocommerce_single_product_image_thumbnail_html', 'custom_unlink_single_product_image', 10, 2);
    

    But second part is tough one 🙂 I tried everything, but result is blank page. May I ask for detailed information? .-)

    Thanks you

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Blank page usually means syntax error in your code. Enable WP_DEBUG whilst you work on this to see the error.

    Thread Starter gore.m

    (@gorem)

    Thanks you. Still cant get it work 🙁
    I enabled WP_Dedug, nothing happened, … result is: blank page, only header is displayed, rest of page is blank without any error notice.
    I think I dont understand exactly what Claudiu Lodromanean mean by: “it passes the attachment id instead of the post id as the second argument”.
    May I ask for help to finish code?
    Thanks you

    Can we please get some help with this function to remove the link? I’m facing exactly the same problem. Thank you!

    This should work…

    function custom_single_product_image_html( $html, $post_id ) {
    	$post_thumbnail_id = get_post_thumbnail_id( $post_id );
    	
        return get_the_post_thumbnail( $post_thumbnail_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
    }
    add_filter('woocommerce_single_product_image_thumbnail_html', 'custom_single_product_image_html', 10, 2);
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Remove link on featured image – since 3.0.0’ is closed to new replies.