Last active
May 20, 2016 08:21
-
-
Save frankschrijvers/f40d3ecf4b19b6f4c7ef to your computer and use it in GitHub Desktop.
Set default images sizes 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
| <?php | |
| //* Do NOT include the opening PHP tag | |
| add_action( 'after_switch_theme', 'wpstudio_woocommerce_image_dimensions', 1 ); | |
| function wpstudio_woocommerce_image_dimensions() { | |
| global $pagenow; | |
| if ( ! isset( $_GET['activated'] ) || $pagenow != 'themes.php' ) { | |
| return; | |
| } | |
| $catalog = array( | |
| 'width' => '400', // px | |
| 'height' => '400', // px | |
| 'crop' => 1 // true | |
| ); | |
| $single = array( | |
| 'width' => '600', // px | |
| 'height' => '600', // px | |
| 'crop' => 1 // true | |
| ); | |
| $thumbnail = array( | |
| 'width' => '300', // px | |
| 'height' => '300', // px | |
| 'crop' => 1 // 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 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment