Skip to content

Instantly share code, notes, and snippets.

@ammist
Last active March 24, 2019 22:52
Show Gist options
  • Save ammist/4f75a3587a4fcaa1e3e642f339129325 to your computer and use it in GitHub Desktop.
Save ammist/4f75a3587a4fcaa1e3e642f339129325 to your computer and use it in GitHub Desktop.
WooCommerce Crop Single Product Image
// filter single product image to enable cropping
add_filter('woocommerce_get_image_size_single', 'bb_crop_woo_image', 100);
function bb_crop_woo_image( $size ){
$size['crop'] = 1;
$size['height'] = 315;
return $size;
}
// Or use a different fixed size image on the gallery in the single product page
add_filter( 'woocommerce_gallery_image_size' , 'bb_medium_image_size' );
function bb_medium_image_size( $image ){
return 'shop_single_image_size';
}
// This ismage size name is from WooCommerce pre 3.x
add_image_size( 'shop_single_image_size', '350', '315', true );
// Redirecting Cart Button
add_filter('woocommerce_add_to_cart_redirect', 'themeprefix_add_to_cart_redirect');
function themeprefix_add_to_cart_redirect() {
global $woocommerce;
$checkout_url = wc_get_checkout_url();
return $checkout_url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment