Skip to content

Instantly share code, notes, and snippets.

@jameskoster
Last active September 19, 2024 12:40
Show Gist options
  • Select an option

  • Save jameskoster/1695731 to your computer and use it in GitHub Desktop.

Select an option

Save jameskoster/1695731 to your computer and use it in GitHub Desktop.

Revisions

  1. jameskoster revised this gist Oct 3, 2014. 1 changed file with 9 additions and 3 deletions.
    12 changes: 9 additions & 3 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -2,13 +2,17 @@
    /**
    * Hook in on activation
    */
    global $pagenow;
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action( 'init', 'yourtheme_woocommerce_image_dimensions', 1 );

    /**
    * Define image sizes
    */
    function yourtheme_woocommerce_image_dimensions() {
    global $pagenow;

    if ( ! isset( $_GET['activated'] ) || $pagenow != 'themes.php' ) {
    return;
    }

    $catalog = array(
    'width' => '400', // px
    'height' => '400', // px
    @@ -31,4 +35,6 @@ function yourtheme_woocommerce_image_dimensions() {
    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
    }
    }

    add_action( 'after_switch_theme', 'yourtheme_woocommerce_image_dimensions', 1 );
  2. jameskoster revised this gist Mar 13, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    * Define image sizes
    */
    function yourtheme_woocommerce_image_dimensions() {
    $catalog = array(
    $catalog = array(
    'width' => '400', // px
    'height' => '400', // px
    'crop' => 1 // true
  3. jameskoster revised this gist Mar 13, 2013. 1 changed file with 27 additions and 22 deletions.
    49 changes: 27 additions & 22 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,34 @@
    <?php
    /*-----------------------------------------------------------------------------------*/
    /* Hook in on activation */
    /*-----------------------------------------------------------------------------------*/

    /**
    * Hook in on activation
    */
    global $pagenow;
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action('init', 'yourtheme_woocommerce_image_dimensions', 1);

    /*-----------------------------------------------------------------------------------*/
    /* Define image sizes / hard crop */
    /*-----------------------------------------------------------------------------------*/
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action( 'init', 'yourtheme_woocommerce_image_dimensions', 1 );

    /**
    * Define image sizes
    */
    function yourtheme_woocommerce_image_dimensions() {
    $catalog = array(
    'width' => '400', // px
    'height' => '400', // px
    'crop' => 1 // true
    );

    // Image sizes
    update_option( 'woocommerce_thumbnail_image_width', '200' ); // Image gallery thumbs
    update_option( 'woocommerce_thumbnail_image_height', '200' );
    update_option( 'woocommerce_single_image_width', '888' ); // Featured product image
    update_option( 'woocommerce_single_image_height', '888' );
    update_option( 'woocommerce_catalog_image_width', '350' ); // Product category thumbs
    update_option( 'woocommerce_catalog_image_height', '350' );
    $single = array(
    'width' => '600', // px
    'height' => '600', // px
    'crop' => 1 // true
    );

    // Hard Crop [0 = false, 1 = true]
    update_option( 'woocommerce_thumbnail_image_crop', 0 );
    update_option( 'woocommerce_single_image_crop', 0 );
    update_option( 'woocommerce_catalog_image_crop', 0 );
    $thumbnail = array(
    'width' => '120', // px
    'height' => '120', // px
    'crop' => 0 // 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
    }
  4. jameskoster revised this gist Feb 8, 2012. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -22,11 +22,8 @@ function yourtheme_woocommerce_image_dimensions() {

    // Hard Crop [0 = false, 1 = true]
    update_option( 'woocommerce_thumbnail_image_crop', 0 );
    update_option( 'woocommerce_thumbnail_image_crop', 0 );
    update_option( 'woocommerce_single_image_crop', 0 );
    update_option( 'woocommerce_single_image_crop', 0 );
    update_option( 'woocommerce_catalog_image_crop', 0 );
    update_option( 'woocommerce_catalog_image_crop', 0 );

    }
    ?>
  5. jameskoster revised this gist Jan 28, 2012. No changes.
  6. jameskoster revised this gist Jan 28, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    /*-----------------------------------------------------------------------------------*/
    /* Hook in on activation */
    /*-----------------------------------------------------------------------------------*/
    @@ -27,4 +28,5 @@ function yourtheme_woocommerce_image_dimensions() {
    update_option( 'woocommerce_catalog_image_crop', 0 );
    update_option( 'woocommerce_catalog_image_crop', 0 );

    }
    }
    ?>
  7. jameskoster revised this gist Jan 28, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -3,13 +3,13 @@
    /*-----------------------------------------------------------------------------------*/

    global $pagenow;
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action('init', 'set_woocommerce_image_dimensions', 1);
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action('init', 'yourtheme_woocommerce_image_dimensions', 1);

    /*-----------------------------------------------------------------------------------*/
    /* Define image sizes / hard crop */
    /*-----------------------------------------------------------------------------------*/

    function set_woocommerce_image_dimensions() {
    function yourtheme_woocommerce_image_dimensions() {

    // Image sizes
    update_option( 'woocommerce_thumbnail_image_width', '200' ); // Image gallery thumbs
  8. jameskoster revised this gist Jan 28, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action('init', 'set_woocommerce_image_dimensions', 1);

    /*-----------------------------------------------------------------------------------*/
    /* Install */
    /* Define image sizes / hard crop */
    /*-----------------------------------------------------------------------------------*/

    function set_woocommerce_image_dimensions() {
  9. jameskoster revised this gist Jan 28, 2012. No changes.
  10. jameskoster created this gist Jan 28, 2012.
    30 changes: 30 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    /*-----------------------------------------------------------------------------------*/
    /* Hook in on activation */
    /*-----------------------------------------------------------------------------------*/

    global $pagenow;
    if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' ) add_action('init', 'set_woocommerce_image_dimensions', 1);

    /*-----------------------------------------------------------------------------------*/
    /* Install */
    /*-----------------------------------------------------------------------------------*/

    function set_woocommerce_image_dimensions() {

    // Image sizes
    update_option( 'woocommerce_thumbnail_image_width', '200' ); // Image gallery thumbs
    update_option( 'woocommerce_thumbnail_image_height', '200' );
    update_option( 'woocommerce_single_image_width', '888' ); // Featured product image
    update_option( 'woocommerce_single_image_height', '888' );
    update_option( 'woocommerce_catalog_image_width', '350' ); // Product category thumbs
    update_option( 'woocommerce_catalog_image_height', '350' );

    // Hard Crop [0 = false, 1 = true]
    update_option( 'woocommerce_thumbnail_image_crop', 0 );
    update_option( 'woocommerce_thumbnail_image_crop', 0 );
    update_option( 'woocommerce_single_image_crop', 0 );
    update_option( 'woocommerce_single_image_crop', 0 );
    update_option( 'woocommerce_catalog_image_crop', 0 );
    update_option( 'woocommerce_catalog_image_crop', 0 );

    }