我已停止使用以下代码生成几种Woocommerce图片大小:
function add_image_insert_override( $sizes ) {
unset($sizes['shop_catalog']);
unset($sizes['shop_thumbnail']);
unset($sizes['woocommerce_thumbnail']);
unset($sizes['woocommerce_gallery_thumbnail']);
return $sizes;
}
add_filter( 'intermediate_image_sizes_advanced', 'add_image_insert_override'
);
但是问题是,当我访问包含这些图像的产品页面时,Woocommerce会尝试每次都生成它们,从而使页面速度非常慢。如何阻止它这样做?
这些呼叫的慢日志条目:
[2019年3月19日23:33:12] [pool sqxmkpfadt] pid 11448 script_filename = /index.php curl_exec()/wp-includes/Requests/Transport/cURL.php:162 request()/wp-includes/class-requests.php:379 request() /wp-includes/class-http.php:370 request() /wp-includes/class-http.php:589 post()/wp-includes/http.php:91 wp_safe_remote_post() /wp-content/plugins/optimus/inc/optimus_request.class.php:470 _do_api_request()/wp-content/plugins/optimus/inc/optimus_request.class.php:389 _do_image_action()/wp-content/plugins/optimus/inc/optimus_request.class.php:318 optimize_upload_images()/ wp-includes / class-wp-hook.php:286 apply_filters()/wp-includes/plugin.php:203 apply_filters() /wp-admin/includes/image.php:293 wp_generate_attachment_metadata() /wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php:354 resize_and_return_image() /wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php:228 may_resize_image()/wp-includes/class-wp-hook.php:286 apply_filters()/wp-includes/plugin.php:203 apply_filters() /wp-includes/media.php:851 wp_get_attachment_image_src() /wp-includes/media.php:873 wp_get_attachment_image() /wp-content/themes/atelier-child/woocommerce/content-product.php:69