【问题标题】:Make WooCommerce thumbnail images as bigger than main product image使 WooCommerce 缩略图图像大于主要产品图像
【发布时间】:2020-11-22 04:20:12
【问题描述】:

我正在使用 Woocommerce 4.2.0 和 Storefront 的子主题。在产品页面中,我想让缩略图图像与主图像一样大(692 像素)。

我的functions.php中有这个:

/**
 * Modify image width theme support.
 */
function iconic_modify_theme_support() {
    $theme_support = get_theme_support( 'woocommerce' );
    $theme_support = is_array( $theme_support ) ? $theme_support[0] : array();

    
    $theme_support['single_image_width'] = 692;
    // $theme_support['thumbnail_image_width'] = 324;

    remove_theme_support( 'woocommerce' );
    add_theme_support( 'woocommerce', $theme_support );
}
add_action( 'after_setup_theme', 'iconic_modify_theme_support', 100 );

【问题讨论】:

    标签: wordpress woocommerce product thumbnails storefront


    【解决方案1】:

    已更新 - 以下内容将动态更新:

    • 禁用弹性滑块
    • 禁用缩放功能
    • 将图库缩略图大小设置为与主产品图片相同的大小

    代码:

    add_filter( 'woocommerce_single_product_flexslider_enabled', '__return_false' ); // Disable slider
    
    add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' ); // Disable zoom
    
    // Set gallery thumbnails size from single product main image size
    add_filter( 'woocommerce_gallery_thumbnail_size', 'filter_gallery_thumbnail_size' );
    function filter_gallery_thumbnail_size( $indexed_size ){
        // Get single product main image size
        $indexed_size = wc_get_image_size( 'woocommerce_thumbnail' );
    
        return array( $indexed_size['width'], $indexed_size['height'] );
    }
    

    代码在您的活动子主题(或活动主题)的functions.php 文件中。经过测试和工作。

    【讨论】:

    • 它现在不适合我。我的functions.php中有以下内容,那已经过时了吗? /*Remove the slider for the product page images */ add_action( 'after_setup_theme', 'remove_hemen_theme_support', 100 ); function remove_hemen_theme_support() { remove_theme_support( 'wc-product-gallery-zoom' ); remove_theme_support( 'wc-product-gallery-lightbox' ); remove_theme_support( 'wc-product-gallery-slider' ); }
    • 我也有这个:function iconic_modify_theme_support() { $theme_support = get_theme_support( 'woocommerce' ); $theme_support = is_array( $theme_support ) ? $theme_support[0] : array(); $theme_support['single_image_width'] = 692; // $theme_support['thumbnail_image_width'] = 324; remove_theme_support( 'woocommerce' ); add_theme_support( 'woocommerce', $theme_support ); } add_action( 'after_setup_theme', 'iconic_modify_theme_support', 100 );
    猜你喜欢
    • 2019-02-09
    • 2021-11-10
    • 2014-12-05
    • 2019-04-18
    • 1970-01-01
    • 2019-02-04
    • 1970-01-01
    • 2016-03-27
    • 2023-03-22
    相关资源
    最近更新 更多