Hard crop option

This commit is contained in:
Mike Jolley 2011-10-09 16:00:21 +01:00
parent f82d6423a7
commit 7167f11c26
2 changed files with 22 additions and 4 deletions

View File

@ -99,9 +99,15 @@ function woocommerce_update_options($options) {
if(isset($value['id']) && isset($_POST[$value['id'].'_width'])) {
update_option($value['id'].'_width', woocommerce_clean($_POST[$value['id'].'_width']));
update_option($value['id'].'_height', woocommerce_clean($_POST[$value['id'].'_height']));
if (isset($_POST[$value['id'].'_crop'])) :
update_option($value['id'].'_crop', 1);
else :
update_option($value['id'].'_crop', 0);
endif;
} else {
update_option($value['id'].'_width', $value['std']);
update_option($value['id'].'_height', $value['std']);
update_option($value['id'].'_crop', 1);
}
else :
@ -147,7 +153,15 @@ function woocommerce_admin_fields($options) {
case 'image_width' :
?><tr valign="top">
<th scope="row" class="titledesc"><?php echo $value['name'] ?></th>
<td class="forminp"><?php _e('Width'); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>_width" id="<?php echo esc_attr( $value['id'] ); ?>_width" type="text" size="3" value="<?php if ( $size = get_option( $value['id'].'_width') ) echo stripslashes($size); else echo $value['std']; ?>" /> <?php _e('Height'); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>_height" id="<?php echo esc_attr( $value['id'] ); ?>_height" type="text" size="3"" value="<?php if ( $size = get_option( $value['id'].'_height') ) echo stripslashes($size); else echo $value['std']; ?>" /> <span class="description"><?php echo $value['desc'] ?></span></td>
<td class="forminp">
<?php _e('Width'); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>_width" id="<?php echo esc_attr( $value['id'] ); ?>_width" type="text" size="3" value="<?php if ( $size = get_option( $value['id'].'_width') ) echo stripslashes($size); else echo $value['std']; ?>" />
<?php _e('Height'); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>_height" id="<?php echo esc_attr( $value['id'] ); ?>_height" type="text" size="3" value="<?php if ( $size = get_option( $value['id'].'_height') ) echo stripslashes($size); else echo $value['std']; ?>" />
<label><?php _e('Hard Crop', 'woothemes'); ?> <input name="<?php echo esc_attr( $value['id'] ); ?>_crop" id="<?php echo esc_attr( $value['id'] ); ?>_crop" type="checkbox" <?php if (get_option( $value['id'].'_crop')!='') checked(get_option( $value['id'].'_crop'), 1); else checked(1); ?> /></label>
<span class="description"><?php echo $value['desc'] ?></span></td>
</tr><?php
break;
case 'select':

View File

@ -100,9 +100,13 @@ function woocommerce_init() {
woocommerce_post_type();
// Image sizes
add_image_size( 'shop_thumbnail', $woocommerce->get_image_size('shop_thumbnail_image_width'), $woocommerce->get_image_size('shop_thumbnail_image_height'), 'true' );
add_image_size( 'shop_catalog', $woocommerce->get_image_size('shop_catalog_image_width'), $woocommerce->get_image_size('shop_catalog_image_height'), 'true' );
add_image_size( 'shop_single', $woocommerce->get_image_size('shop_single_image_width'), $woocommerce->get_image_size('shop_single_image_height'), 'true' );
$shop_thumbnail_crop = (get_option('shop_thumbnail_image_crop')==1) ? 'true' : 'false';
$shop_catalog_crop = (get_option('shop_catalog_image_crop')==1) ? 'true' : 'false';
$shop_single_crop = (get_option('shop_single_image_crop')==1) ? 'true' : 'false';
add_image_size( 'shop_thumbnail', $woocommerce->get_image_size('shop_thumbnail_image_width'), $woocommerce->get_image_size('shop_thumbnail_image_height'), $shop_thumbnail_crop );
add_image_size( 'shop_catalog', $woocommerce->get_image_size('shop_catalog_image_width'), $woocommerce->get_image_size('shop_catalog_image_height'), $shop_catalog_crop );
add_image_size( 'shop_single', $woocommerce->get_image_size('shop_single_image_width'), $woocommerce->get_image_size('shop_single_image_height'), $shop_single_crop );
// Include template functions here so they are pluggable by themes
include_once( 'woocommerce_template_functions.php' );