How to change WooCommerce thumbnail crop position?
To change existing images sizes (crop option) within your active child theme or theme, you need to use 'after_switch_theme'
WordPress hook.
Since WordPress 3.9+ an awesome new feature among many, is the added ability to now control crop position of images uploaded in WordPress.
I don't know if crop potion advanced option is available to woocommerce images sizes, you will have to test it.
The available options for crop position are:
left topleft centerleft bottomright topright centerright bottomcenter topcenter centercenter bottom
So based on this snippet from wooThemes and and (this relative new) crop options of WordPress, you can try this:
function yourtheme_woocommerce_image_dimensions() { global $pagenow; if ( ! isset( $_GET['activated'] ) || $pagenow != 'themes.php' ) { return; } $catalog = array( 'width' => '300', // px 'height' => '400', // px 'crop' => array( 'center', 'bottom' ) // New crop options to try. ); /* $single = array( 'width' => '600', // px 'height' => '600', // px 'crop' => 1 // true ); $thumbnail = array( 'width' => '120', // px 'height' => '120', // px 'crop' => 0 // 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 */}add_action( 'after_switch_theme', 'yourtheme_woocommerce_image_dimensions', 1 );
You will need to paste this code snippet in function.php file of your active child theme or themeā¦
You can comment/uncomment the code (or remove some portions) to feet your needs. This code will overwrite define options in WooCommerce settings > Products > Display (Product Images).
ACTIVATION:
You will need to switch your active theme to another and then switch back to activate it.
References: