无法删除 WooCommerce 图像缩放

Can't remove WooCommerce's image zoom

我正在尝试从使用 WooCommerce 的自定义主题网站中删除图像缩放。这是我尝试在 functions.php 文件中添加的内容:

add_action( 'after_setup_theme', 'remove_pgz_theme_support', 100 );

function remove_pgz_theme_support() {
    remove_theme_support( 'wc-product-gallery-zoom' );
}

还有这个

add_action( 'wp', 'remove_pgz_theme_support', 20 );

function remove_pgz_theme_support() {
    remove_theme_support( 'wc-product-gallery-zoom' );
}

我花了一些时间在谷歌上搜索,但答案总是建议按照上述思路尝试一些事情。

我禁用所有图像效果:

add_action('wp', 'remove_woo_image_effects');
function remove_woo_image_effects() {

    // this should be disable the gallery slider and lightbox
    remove_theme_support('wc-product-gallery-lightbox');
    remove_theme_support('wc-product-gallery-slider');

    // this should be disable the zoom
    remove_theme_support('wc-product-gallery-zoom');
}

我用 DIVI 和我的自定义主题中的两个测试了它
custom theme

在此处检查

对我有用的解决方案是将以下内容添加到您的 functions.php 文件

// Add WooCommerce support
function add_woocommerce_support() {
    add_theme_support( 'woocommerce' );
}

add_action( 'after_setup_theme', 'add_woocommerce_support' );