Skip to content

Instantly share code, notes, and snippets.

@huytrq
Created October 31, 2018 03:17
Show Gist options
  • Select an option

  • Save huytrq/f9f85adf691ec947c49dea372f53f9c4 to your computer and use it in GitHub Desktop.

Select an option

Save huytrq/f9f85adf691ec947c49dea372f53f9c4 to your computer and use it in GitHub Desktop.
Adding Images in WooCommerce
/**
* Change your catalog images with a specific size
**/
add_filter( 'woocommerce_get_image_size_thumbnail', 'ci_theme_override_woocommerce_image_size_thumbnail' );
function ci_theme_override_woocommerce_image_size_thumbnail( $size ) {
// Catalog images: specific size
return array(
'width' => 750,
'height' => 430,
'crop' => 1,
);
}
/**
* Change the Single Product image
**/
add_filter( 'woocommerce_get_image_size_single', 'ci_theme_override_woocommerce_image_size_single' );
function ci_theme_override_woocommerce_image_size_single( $size ) {
// Single product image: square
return array(
'width' => 750,
'height' => 750,
'crop' => 1,
);
}
/**
* Change gallery thumbnails
**/
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', 'ci_theme_override_woocommerce_image_size_gallery_thumbnail' );
function ci_theme_override_woocommerce_image_size_gallery_thumbnail( $size ) {
// Gallery thumbnails: proportional, max width 200px
return array(
'width' => 200,
'height' => '',
'crop' => 0,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment