Last active
June 28, 2018 06:36
-
-
Save raphaelkross/71abbb6c8ed8946a040466413c338d4b to your computer and use it in GitHub Desktop.
Configure Image Sizes when Theme is Activated
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 | |
| /** | |
| * Change thumbnail sizes after theme activation | |
| * | |
| * @return void | |
| */ | |
| function theme_prefix_activation() { | |
| // Set default WordPress' sizes. | |
| update_option( 'thumbnail_size_h', 120 ); | |
| update_option( 'thumbnail_size_w', 80 ); | |
| update_option( 'medium_size_w', 480 ); | |
| update_option( 'medium_size_h', 480 ); | |
| update_option( 'large_size_w', 1200 ); | |
| update_option( 'large_size_h', 1200 ); | |
| // Modify WooCommerce's sizes. | |
| update_option( 'shop_catalog_image_size', array( 'width' => 480, 'height' => 600, 'crop' => false ) ); | |
| update_option( 'shop_single_image_size', array( 'width' => 510, 'height' => 600, 'crop' => true ) ); | |
| update_option( 'shop_thumbnail_image_size', array( 'width' => 120, 'height' => 120, 'crop' => true ) ); | |
| } | |
| add_action( 'after_switch_theme', 'theme_prefix_activation', 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment