Created
October 11, 2016 13:43
-
-
Save smeric/71f60753d0d8d44e64e0d48e0e5123ef to your computer and use it in GitHub Desktop.
Overwrite default thumbnails sizes after WooCommerce installation
This file contains 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 | |
add_action( 'after_setup_theme', 'mytheme_woocommerce_set_image_dimensions' ); | |
function mytheme_woocommerce_set_image_dimensions() { | |
// Do not set sizes multiple times | |
if ( ! get_option( 'mytheme_shop_image_sizes_set' ) ) { | |
$catalog = array( | |
'width' => '768', // px | |
'height' => '', // px | |
'crop' => 0 // no-crop | |
); | |
$single = array( | |
'width' => '595', // px | |
'height' => '', // px | |
'crop' => 0 // no-crop | |
); | |
$thumbnail = array( | |
'width' => '', // px | |
'height' => '127', // px | |
'crop' => 0 // no-crop | |
); | |
// 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 | |
// Set "images sizes set" option | |
add_option( 'mytheme_shop_image_sizes_set', 1 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment