【发布时间】:2017-02-01 00:58:21
【问题描述】:
每当我转到 WooCommerce > 设置 > 产品 > 显示 时,更改图像尺寸并按“保存更改”它不会保存更改。
我知道我必须在保存更改后使用Regenerate Thumbnails plugin,但问题是“保存更改”按钮不会更改设置。
我的主题名为 Converio,converio/functions.php 包含以下代码:
if (class_exists('Woocommerce')) {
include('functions/woocommerce-support.php');
}
converio/functions/woocommerce-support.php 包含以下代码:
function converio_woocommerce_image_dimensions() {
$catalog = array(
'width' => '560', // px
'height' => '627', // px
'crop' => 1 // true
);
$single = array(
'width' => '560', // px
'height' => '626', // px
'crop' => 1 // true
);
$thumbnail = array(
'width' => '60', // px
'height' => '60', // px
'crop' => 1 // false
);
// Image sizes
update_option('shop_catalog_image_size', $catalog); // Product category thumbs
update_option('shop_single_image_size', $single); // Single product image
update_option('shop_thumbnail_image_size', $thumbnail); // Image gallery thumbs
}
由于我不想通过删除代码来更改父主题,因此我尝试通过在子主题中覆盖它来自行解决问题,但没有运气。
我制作了一个converio-child-theme/functions.php并添加了以下代码:
if (class_exists('Woocommerce')) {
include('converio-child-theme/functions/woocommerce-image-dimensions-fix.php');
}
然后我创建了 converio-child-theme/functions/woocommerce-image-dimensions-fix.php 并添加了以下代码:
function converio_woocommerce_image_dimensions_fix() {
$catalog = array(
'width' => '560', // px
'height' => '627', // px
'crop' => 1 // true
);
$single = array(
'width' => '560', // px
'height' => '626', // px
'crop' => 1 // true
);
$thumbnail = array(
'width' => '60', // px
'height' => '60', // px
'crop' => 1 // false
);
// Image sizes
update_option('shop_catalog_image_size', '', false); // Product category thumbs
update_option('shop_single_image_size', '', false); // Single product image
update_option('shop_thumbnail_image_size', '', false); // Image gallery thumbs
}
但它不能解决图像恢复默认的问题,在保存更改后。谁能告诉我,我做错了什么?
【问题讨论】:
标签: php wordpress woocommerce