【问题标题】:Woocommerce image alternative sizesWoocommerce 图像替代尺寸
【发布时间】:2016-09-01 20:40:52
【问题描述】:

我正在修改 woocommerce 插件,并尝试使产品图片和缩略图大小相同(全尺寸设置为 400x600)。

product_thumbnails.php 调用了 180x180 缩略图,但是我无法找到不同尺寸的 codex。有谁知道我如何调用全尺寸 400x600 图像而不是 180x180?

        echo apply_filters(
            'woocommerce_single_product_image_thumbnail_html',
            sprintf(
                '<a href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a>',
                esc_url( $props['url'] ),
                esc_attr( $image_class ),
                esc_attr( $props['caption'] ),
                wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ), 0, $props )
            ),
            $attachment_id,
            $post->ID,
            esc_attr( $image_class )
        );

        $loop++;
    }

我一直试图修改这一行无济于事:

wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ), 0, $props )

【问题讨论】:

    标签: php wordpress image woocommerce


    【解决方案1】:

    看到This site,你可以轻松使用以下:

    // 定义 single_product_small_thumbnail_size 回调

    function filter_single_product_small_thumbnail_size($shop_catalog) { 

    返回“满”;

    }; // 添加过滤器

    add_filter('single_product_small_thumbnail_size', 'filter_single_product_small_thumbnail_size', 99, 1);

    您需要将其复制到您的主题 functions.php 中,并且 WOO 显示产品缩略图的任何地方都应该为您提供完整尺寸的图像。

    【讨论】:

      猜你喜欢
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多