Created
October 31, 2018 03:17
-
-
Save huytrq/f9f85adf691ec947c49dea372f53f9c4 to your computer and use it in GitHub Desktop.
Adding Images in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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