在woocommerce 3中调整产品图像的缩放放大倍数 [英] Adjusting product image's Zoom magnification factor in woocommerce 3

查看:64
本文介绍了在woocommerce 3中调整产品图像的缩放放大倍数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Woocommerce中,我使用的是Storefront主题,并且一直想知道是否有一种方法可以在将产品图像悬停在产品图像上时对其进行调整.

非常感谢您的帮助.

解决方案

这可以通过使用 woocommerce_single_product_zoom_options 专用过滤器挂钩来实现.

选项数组中的未记录的可用参数钩子是:

  $ zoom_options = array( 

 'url'=>错误的,'callback'=>错误的,'target'=>错误的,'持续时间'=>120,//以毫秒为单位的过渡(默认值为120)'on'=>'mouseover',//其他选项:抓取,单击,切换(默认为鼠标悬停)'触摸'=>true,//启用触摸回退'onZoomIn'=>错误的,'onZoomOut'=>错误的,'放大'=>1,//缩放倍率:(默认值为1 | 0到1之间的浮点数)); 

相关:

在将放大倍数设置为 0.7 之前:

With Woocommerce, I'm using the Storefront theme and have been wondering if there is a way to adjust the zooming level imposed on the product image upon hovering on it.

Any help is greatly appreciated.

解决方案

This is possible using woocommerce_single_product_zoom_options dedicated filter hook.

The hook undocumented available parameters in the options array are:

$zoom_options = array (

    'url' => false,
    'callback' => false,
    'target' => false,
    'duration' => 120, // Transition in milli seconds (default is 120)
    'on' => 'mouseover', // other options: grab, click, toggle (default is mouseover)
    'touch' => true, // enables a touch fallback
    'onZoomIn' => false,
    'onZoomOut' => false,
    'magnify' => 1, // Zoom magnification: (default is 1  |  float number between 0 and 1)
);

Related: Available parameters details for WooCommerce product image zoom options

Usage with woocommerce_single_product_zoom_options filter hook to change the magnification level (for example we mill minimize the zoom level a bit less):

add_filter( 'woocommerce_single_product_zoom_options', 'custom_single_product_zoom_options' );
function custom_single_product_zoom_options( $zoom_options ) {
    // Changing the magnification level:
    $zoom_options['magnify'] = 0.7;

    return $zoom_options;
}

Code goes in functions.php file of your active child theme (or active theme). Tested and work.

Before with default magnification (set to 1):

Before with magnification set to 0.7:

这篇关于在woocommerce 3中调整产品图像的缩放放大倍数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆