• Resolved Huan

    (@daodaotw)


    Hi,

    This no longer work for block themes + WC blocks (Product Image Gallery block in this case):

    function remove_zoom_lightbox_slider() {
    	remove_theme_support( 'wc-product-gallery-zoom' );
    	remove_theme_support( 'wc-product-gallery-lightbox' );
    	remove_theme_support( 'wc-product-gallery-slider' );
    }
    add_action( 'after_setup_theme', 'remove_zoom_lightbox_slider', 99 );

    My test site has no plugin other than WC.

    Is there up-to-date documentation I can refer to for other image-related functions for WC blocks? I’d like to turn on/off native functionalities, NOT to develop new ones.

    Thanks!

    • This topic was modified 2 years, 5 months ago by Huan.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Saif

    (@babylon1999)

    Hello @daodaotw,

    Thank you for reaching out!

    This no longer work for block themes + WC blocks (Product Image Gallery block in this case):

    I managed to replicate this in twenty twenty-three. It seems to be an expected behaviour, but I’ll further investigate to confirm. I’ll ensure to update the thread if it turns out to be a bug. :‎)

    Meanwhile, consider disabling these using the following filter.

    add_filter( 'woocommerce_single_product_photoswipe_enabled', '__return_false' );

    Hope this helps!

    Thread Starter Huan

    (@daodaotw)

    Thank you @babylon1999 . Your code (missing zoom and lightbox disabling) doesn’t work…

    Also there’s no WC image sizes settings in WP admin, should I work on functions.php instead?

    Thread Starter Huan

    (@daodaotw)

    This PHP+CSS combination seems to work:

    function wc_remove_image_effect_support() {
    	remove_theme_support( 'wc-product-gallery-zoom' );
    	remove_theme_support( 'wc-product-gallery-lightbox' );
    }
    add_action( 'wp', 'wc_remove_image_effect_support', 99 );
    .woocommerce .woocommerce-product-gallery__image {
        pointer-events: none;
    }

    Any improvement idea is appreciated.

    Saif

    (@babylon1999)

    Thank you @babylon1999 . Your code (missing zoom and lightbox disabling) doesn’t work…

    I did some digging, and you’re right, the zoom option has its own filter. Sorry for any confusion caused. :‎)

    Any improvement idea is appreciated.

    It’s not really an improvement, but if you prefer disabling these with filters, you can try:

    add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' );
    add_filter( 'woocommerce_single_product_photoswipe_enabled', '__return_false' );
    add_filter( 'woocommerce_single_product_flexslider_enabled', '__return_false' );

    Let us know if you have any other questions or if I misunderstood your request.

    Thread Starter Huan

    (@daodaotw)

    Thanks @babylon1999, with your help, this finally achieves what I want by fixing the root cause:

    // Remove Single Product gallery image zoom.
    add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' );
    
    // Remove Single Product gallery image link.
    function wc_remove_link_on_thumbnails( $html ) {
    	return strip_tags( $html, '<div><img>' );
    }
    add_filter( 'woocommerce_single_product_image_thumbnail_html', 'wc_remove_link_on_thumbnails' );

    Hope this helps others too. Again, any improvement is welcome.

    Saif

    (@babylon1999)

    Hope this helps others too

    Glad to know everything is working now, and thank you for sharing your solution with the community. :‎)

    I’ll mark the thread as solved, feel free to create a new one if you have any other questions.

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

The topic ‘remove_theme_support no longer works for WC blocks?’ is closed to new replies.