Widths and aspect ratios

This commit is contained in:
Mike Jolley 2017-11-07 18:32:43 +00:00
parent 54bd73d619
commit e025caf177
21 changed files with 296 additions and 210 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3139,6 +3139,10 @@ img.help_tip {
box-sizing: border-box;
}
input[size] {
width: auto !important;
}
// Ignore nested inputs.
table {
select,
@ -3265,6 +3269,69 @@ img.help_tip {
.wc_emails_wrapper {
padding: 0 15px 10px 0;
}
.woocommerce-thumbnail-cropping {
margin: 0;
padding: 0;
input[type=radio] {
vertical-align: top;
margin-top: 2px;
}
label {
display: inline-block;
span.description {
margin-top: .5em;
display:block;
color: #999;
}
span.woocommerce-thumbnail-cropping-aspect-ratio {
margin-top: .5em;
display:block;
}
}
li {
margin: 5px 0 1.5em;
padding: 0;
}
}
.woocommerce-thumbnail-preview {
float:right;
width: 320px;
h4 {
margin-top: 0;
}
.woocommerce-thumbnail-preview-block {
text-align: center;
width: 100px;
margin: 0 10px 0 0;
float: left;
.woocommerce-thumbnail-preview-block__image {
width: 90px;
height: 90px;
border: 5px solid #fff;
background: #ddd;
box-shadow: 0 0 1px #ccc;
margin: 0 0 10px;
}
.woocommerce-thumbnail-preview-block__text {
width: random( 10 / 2 ) + 1 + em;
background: #ddd;
margin: 0 auto 10px;
height: 10px;
}
.woocommerce-thumbnail-preview-block__button {
width: 50px;
height: 20px;
background: #ddd;
margin: 0 auto;
}
}
.woocommerce-thumbnail-preview-block:last-child {
margin: 0;
}
}
}
}

View File

@ -124,4 +124,43 @@
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
return false;
});
// Thumbnail cropping option updates and preview.
$( '.woocommerce-thumbnail-cropping' )
.on( 'change', 'input', function() {
var value = $( '.woocommerce-thumbnail-cropping input:checked' ).val(),
$preview_images = $( '.woocommerce-thumbnail-preview-block__image' );
if ( 'custom' === value ) {
var width_ratio = Math.max( parseInt( $( 'input[name="thumbnail_cropping_aspect_ratio_width"]' ).val(), 10 ), 1 ),
height_ratio = Math.max( parseInt( $( 'input[name="thumbnail_cropping_aspect_ratio_height"]' ).val(), 10 ), 1 ),
height = ( 90 / width_ratio ) * height_ratio;
$preview_images.animate( { height: height + 'px' }, 200 );
$( '.woocommerce-thumbnail-cropping-aspect-ratio' ).slideDown( 200 );
} else if ( 'uncropped' === value ) {
var heights = [ '120', '60', '80' ];
$preview_images.each( function( index, element ) {
var height = heights[ index ];
$( element ).animate( { height: height + 'px' }, 200 );
} );
$( '.woocommerce-thumbnail-cropping-aspect-ratio' ).hide();
} else {
$preview_images.animate( { height: '90px' }, 200 );
$( '.woocommerce-thumbnail-cropping-aspect-ratio' ).hide();
}
return false;
});
$( '.woocommerce-thumbnail-cropping' ).find( 'input' ).change();
})( jQuery );

View File

@ -1 +1 @@
!function(t){t("select#woocommerce_allowed_countries").change(function(){"specific"===t(this).val()?(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").show()):"all_except"===t(this).val()?(t(this).closest("tr").next("tr").show(),t(this).closest("tr").next().next("tr").hide()):(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").hide())}).change(),t("select#woocommerce_ship_to_countries").change(function(){"specific"===t(this).val()?t(this).closest("tr").next("tr").show():t(this).closest("tr").next("tr").hide()}).change(),t("input#woocommerce_manage_stock").change(function(){t(this).is(":checked")?t(this).closest("tbody").find(".manage_stock_field").closest("tr").show():t(this).closest("tbody").find(".manage_stock_field").closest("tr").hide()}).change(),t(".colorpick").iris({change:function(e,i){t(this).parent().find(".colorpickpreview").css({backgroundColor:i.color.toString()})},hide:!0,border:!0}).on("click focus",function(e){e.stopPropagation(),t(".iris-picker").hide(),t(this).closest("td").find(".iris-picker").show(),t(this).data("original-value",t(this).val())}).on("change",function(){t(this).is(".iris-error")&&(t(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?t(this).val(t(this).data("original-value")).change():t(this).val("").change())}),t("body").on("click",function(){t(".iris-picker").hide()}),t(function(){var e=!1;t("input, textarea, select, checkbox").change(function(){e=!0}),t(".woo-nav-tab-wrapper a").click(function(){window.onbeforeunload=e?function(){return woocommerce_settings_params.i18n_nav_warning}:""}),t(".submit input").click(function(){window.onbeforeunload=""})}),t("table.wc_gateways tbody, table.wc_shipping tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,helper:function(e,i){return i.children().each(function(){t(this).width(t(this).width())}),i.css("left","0"),i},start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style")}}),t(".woocommerce").on("click",".select_all",function(){return t(this).closest("td").find("select option").attr("selected","selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".woocommerce").on("click",".select_none",function(){return t(this).closest("td").find("select option").removeAttr("selected"),t(this).closest("td").find("select").trigger("change"),!1})}(jQuery);
!function(t){t("select#woocommerce_allowed_countries").change(function(){"specific"===t(this).val()?(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").show()):"all_except"===t(this).val()?(t(this).closest("tr").next("tr").show(),t(this).closest("tr").next().next("tr").hide()):(t(this).closest("tr").next("tr").hide(),t(this).closest("tr").next().next("tr").hide())}).change(),t("select#woocommerce_ship_to_countries").change(function(){"specific"===t(this).val()?t(this).closest("tr").next("tr").show():t(this).closest("tr").next("tr").hide()}).change(),t("input#woocommerce_manage_stock").change(function(){t(this).is(":checked")?t(this).closest("tbody").find(".manage_stock_field").closest("tr").show():t(this).closest("tbody").find(".manage_stock_field").closest("tr").hide()}).change(),t(".colorpick").iris({change:function(e,i){t(this).parent().find(".colorpickpreview").css({backgroundColor:i.color.toString()})},hide:!0,border:!0}).on("click focus",function(e){e.stopPropagation(),t(".iris-picker").hide(),t(this).closest("td").find(".iris-picker").show(),t(this).data("original-value",t(this).val())}).on("change",function(){t(this).is(".iris-error")&&(t(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?t(this).val(t(this).data("original-value")).change():t(this).val("").change())}),t("body").on("click",function(){t(".iris-picker").hide()}),t(function(){var e=!1;t("input, textarea, select, checkbox").change(function(){e=!0}),t(".woo-nav-tab-wrapper a").click(function(){window.onbeforeunload=e?function(){return woocommerce_settings_params.i18n_nav_warning}:""}),t(".submit input").click(function(){window.onbeforeunload=""})}),t("table.wc_gateways tbody, table.wc_shipping tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,helper:function(e,i){return i.children().each(function(){t(this).width(t(this).width())}),i.css("left","0"),i},start:function(t,e){e.item.css("background-color","#f6f6f6")},stop:function(t,e){e.item.removeAttr("style")}}),t(".woocommerce").on("click",".select_all",function(){return t(this).closest("td").find("select option").attr("selected","selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".woocommerce").on("click",".select_none",function(){return t(this).closest("td").find("select option").removeAttr("selected"),t(this).closest("td").find("select").trigger("change"),!1}),t(".woocommerce-thumbnail-cropping").on("change","input",function(){var e=t(".woocommerce-thumbnail-cropping input:checked").val(),i=t(".woocommerce-thumbnail-preview-block__image");if("custom"===e){var o=90/Math.max(parseInt(t('input[name="thumbnail_cropping_aspect_ratio_width"]').val(),10),1)*Math.max(parseInt(t('input[name="thumbnail_cropping_aspect_ratio_height"]').val(),10),1);i.animate({height:o+"px"},200),t(".woocommerce-thumbnail-cropping-aspect-ratio").slideDown(200)}else if("uncropped"===e){var c=["120","60","80"];i.each(function(e,i){var o=c[e];t(i).animate({height:o+"px"},200)}),t(".woocommerce-thumbnail-cropping-aspect-ratio").hide()}else i.animate({height:"90px"},200),t(".woocommerce-thumbnail-cropping-aspect-ratio").hide();return!1}),t(".woocommerce-thumbnail-cropping").find("input").change()}(jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -491,7 +491,7 @@ class WC_Admin_Settings {
}
break;
// Image width settings
// Image width settings. @todo deprecate and remove in 4.0. No longer needed by core.
case 'image_width' :
$image_size = str_replace( '_image_size', '', $value['id'] );
@ -519,6 +519,73 @@ class WC_Admin_Settings {
</tr><?php
break;
// Width in pixels custom input. DEVELOPERS: This is private. Re-use at your own risk.
case 'width_in_pixels' :
$option_value = self::get_option( $value['id'], $value['default'] );
?><tr valign="top">
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?> <?php echo $tooltip_html; ?></th>
<td class="forminp">
<input
name="<?php echo esc_attr( $value['id'] ); ?>"
id="<?php echo esc_attr( $value['id'] ); ?>"
type="text"
size="3"
value="<?php echo esc_attr( $option_value ); ?>" /> px
</td>
</tr><?php
break;
// Thumbnail cropping setting. DEVELOPERS: This is private. Re-use at your own risk.
case 'thumbnail_cropping' :
$option_value = self::get_option( $value['id'], $value['default'] );
$width = get_option( 'woocommerce_thumbnail_cropping_aspect_ratio_width', 4 );
$height = get_option( 'woocommerce_thumbnail_cropping_aspect_ratio_height', 3 );
?><tr valign="top">
<th scope="row" class="titledesc"><?php echo esc_html( $value['title'] ) ?> <?php echo $tooltip_html; ?></th>
<td class="forminp">
<div class="woocommerce-thumbnail-preview hide-if-no-js">
<h4><?php esc_html_e( 'Preview', 'woocommerce' ); ?></h4>
<div class="woocommerce-thumbnail-preview-block">
<div class="woocommerce-thumbnail-preview-block__image"></div>
<div class="woocommerce-thumbnail-preview-block__text"></div>
<div class="woocommerce-thumbnail-preview-block__button"></div>
</div>
<div class="woocommerce-thumbnail-preview-block">
<div class="woocommerce-thumbnail-preview-block__image"></div>
<div class="woocommerce-thumbnail-preview-block__text"></div>
<div class="woocommerce-thumbnail-preview-block__button"></div>
</div>
<div class="woocommerce-thumbnail-preview-block">
<div class="woocommerce-thumbnail-preview-block__image"></div>
<div class="woocommerce-thumbnail-preview-block__text"></div>
<div class="woocommerce-thumbnail-preview-block__button"></div>
</div>
</div>
<ul class="woocommerce-thumbnail-cropping">
<li>
<input type="radio" name="thumbnail_cropping" id="thumbnail_cropping_1_1" value="1:1" <?php checked( $option_value, '1:1' ); ?> />
<label for="thumbnail_cropping_1_1">1:1<br/><span class="description"><?php esc_html_e( 'Images will be cropped into a square', 'woocommerce' ); ?></span></label>
</li>
<li>
<input type="radio" name="thumbnail_cropping" id="thumbnail_cropping_custom" value="custom" <?php checked( $option_value, 'custom' ); ?> />
<label for="thumbnail_cropping_custom">
<?php esc_html_e( 'Custom', 'woocommerce' ); ?><br/><span class="description"><?php esc_html_e( 'Images will be cropped to a custom aspect ratio', 'woocommerce' ); ?></span>
<span class="woocommerce-thumbnail-cropping-aspect-ratio">
<input name="thumbnail_cropping_aspect_ratio_width" type="text" size="3" value="<?php echo $width; ?>" /> : <input name="thumbnail_cropping_aspect_ratio_height" type="text" size="3" value="<?php echo $height; ?>" />
</span>
</label>
</li>
<li>
<input type="radio" name="thumbnail_cropping" id="thumbnail_cropping_uncropped" value="uncropped" <?php checked( $option_value, 'uncropped' ); ?> />
<label for="thumbnail_cropping_uncropped"><?php esc_html_e( 'Uncropped', 'woocommerce' ); ?><br/><span class="description"><?php esc_html_e( 'Images will display using the aspect ratio in which they were uploaded', 'woocommerce' ); ?></span></label>
</li>
</ul>
</td>
</tr><?php
break;
// Single page selects
case 'single_select_page' :
@ -711,6 +778,17 @@ class WC_Admin_Settings {
$value['crop'] = $option['default']['crop'];
}
break;
case 'thumbnail_cropping' :
$value = wc_clean( $raw_value );
if ( 'custom' === $value ) {
update_option( 'woocommerce_thumbnail_cropping_aspect_ratio_width', wc_clean( wp_unslash( $_POST['thumbnail_cropping_aspect_ratio_width'] ) ) );
update_option( 'woocommerce_thumbnail_cropping_aspect_ratio_height', wc_clean( wp_unslash( $_POST['thumbnail_cropping_aspect_ratio_height'] ) ) );
} else {
update_option( 'woocommerce_thumbnail_cropping_aspect_ratio_width', '4' );
update_option( 'woocommerce_thumbnail_cropping_aspect_ratio_height', '3' );
}
break;
case 'select':
$allowed_values = empty( $option['options'] ) ? array() : array_keys( $option['options'] );
if ( empty( $option['default'] ) && empty( $allowed_values ) ) {

View File

@ -164,75 +164,52 @@ class WC_Settings_Products extends WC_Settings_Page {
$theme_support = get_theme_support( 'woocommerce' );
$theme_support = is_array( $theme_support ) ? $theme_support[0]: false;
$theme_defines_all_sizes = false;
$image_settings = array();
if ( isset( $theme_support['shop_thumbnail_image_size'], $theme_support['shop_single_image_size'], $theme_support['shop_catalog_image_size'] ) ) {
$theme_defines_all_sizes = true;
}
if ( ! $theme_defines_all_sizes ) {
$image_settings[] = array(
$image_settings = array(
array(
'title' => __( 'Product images', 'woocommerce' ),
'type' => 'title',
'desc' => sprintf( __( 'These settings affect the display and dimensions of images in your catalog - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to <a target="_blank" href="%s">regenerate your thumbnails</a>.', 'woocommerce' ), 'https://wordpress.org/plugins/regenerate-thumbnails/' ),
'desc' => __( 'These settings change how product images are displayed in your catalog.', 'woocommerce' ),
'id' => 'image_options',
);
}
if ( ! isset( $theme_support['shop_catalog_image_size'] ) ) {
$image_settings[] = array(
'title' => __( 'Catalog images', 'woocommerce' ),
'desc' => __( 'This size is usually used in product listings. (W x H)', 'woocommerce' ),
'id' => 'shop_catalog_image_size',
),
'single_image_width' => array(
'title' => __( 'Main image width', 'woocommerce' ),
'desc' => __( 'This is the width used by the main image on single product pages. These images will be uncropped.', 'woocommerce' ),
'id' => 'woocommerce_single_image_width',
'css' => '',
'type' => 'image_width',
'default' => array(
'width' => '300',
'height' => '300',
'crop' => 1,
),
'type' => 'width_in_pixels',
'default' => 600,
'desc_tip' => true,
);
}
if ( ! isset( $theme_support['shop_single_image_size'] ) ) {
$image_settings[] = array(
'title' => __( 'Single product image', 'woocommerce' ),
'desc' => __( 'This is the size used by the main image on the product page. (W x H)', 'woocommerce' ),
'id' => 'shop_single_image_size',
),
'thumbnail_image_width' => array(
'title' => __( 'Thumbnail width', 'woocommerce' ),
'desc' => __( 'This size is used for product archives and product listings.', 'woocommerce' ),
'id' => 'woocommerce_thumbnail_image_width',
'css' => '',
'type' => 'image_width',
'default' => array(
'width' => '600',
'height' => '600',
'crop' => 1,
),
'type' => 'width_in_pixels',
'default' => 300,
'desc_tip' => true,
);
}
if ( ! isset( $theme_support['shop_thumbnail_image_size'] ) ) {
$image_settings[] = array(
'title' => __( 'Product thumbnails', 'woocommerce' ),
'desc' => __( 'This size is usually used for the gallery of images on the product page. (W x H)', 'woocommerce' ),
'id' => 'shop_thumbnail_image_size',
),
array(
'title' => __( 'Thumbnail cropping', 'woocommerce' ),
'desc' => __( 'This determines how thumbnails appear. Widths will be fixed, whilst heights may vary.', 'woocommerce' ),
'id' => 'woocommerce_thumbnail_cropping',
'css' => '',
'type' => 'image_width',
'default' => array(
'width' => '180',
'height' => '180',
'crop' => 1,
),
'desc_tip' => true,
);
}
if ( ! $theme_defines_all_sizes ) {
$image_settings[] = array(
'type' => 'thumbnail_cropping',
'default' => '1:1',
'desc_tip' => false,
),
array(
'type' => 'sectionend',
'id' => 'image_options',
);
),
);
if ( isset( $theme_support['single_image_width'] ) ) {
unset( $image_settings['single_image_width'] );
}
if ( isset( $theme_support['thumbnail_image_width'] ) ) {
unset( $image_settings['thumbnail_image_width'] );
}
$settings = apply_filters( 'woocommerce_product_settings', array_merge( $settings, $image_settings ) );

View File

@ -545,22 +545,24 @@ final class WooCommerce {
* and defining an array of args. If these are not defined, we will use defaults. This is
* handled in wc_get_image_size function.
*
* Supported sizes:
* 3.3 sizes:
*
* shop_thumbnail - This is used for gallery thumbnails and in widgets.
* shop_catalog - This is the size used in archives/catalog/grid based listings of products.
* shop_single - This is the size used on single product pages for the main product image.
* thumbnail - Used in product listings.
* single - Used on single product pages for the main image.
*
* shop_thumbnail, shop_single, shop_catalog registered for bw compat. @todo remove in 4.0.
*
* @since 2.3
*/
private function add_image_sizes() {
$shop_thumbnail = wc_get_image_size( 'shop_thumbnail' );
$shop_catalog = wc_get_image_size( 'shop_catalog' );
$shop_single = wc_get_image_size( 'shop_single' );
$thumbnail = wc_get_image_size( 'thumbnail' );
$single = wc_get_image_size( 'single' );
add_image_size( 'shop_thumbnail', $shop_thumbnail['width'], $shop_thumbnail['height'], $shop_thumbnail['crop'] );
add_image_size( 'shop_catalog', $shop_catalog['width'], $shop_catalog['height'], $shop_catalog['crop'] );
add_image_size( 'shop_single', $shop_single['width'], $shop_single['height'], $shop_single['crop'] );
add_image_size( 'woocommerce_thumbnail', $thumbnail['width'], $thumbnail['height'], $thumbnail['crop'] );
add_image_size( 'woocommerce_single', $single['width'], $single['height'], $single['crop'] );
add_image_size( 'shop_thumbnail', $thumbnail['width'], $thumbnail['height'], $shop_thumbnail['crop'] );
add_image_size( 'shop_catalog', $thumbnail['width'], $thumbnail['height'], $thumbnail['crop'] );
add_image_size( 'shop_single', $single['width'], $single['height'], $single['crop'] );
}
/**

View File

@ -29,21 +29,8 @@ class WC_Twenty_Eleven {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'woocommerce', array(
'shop_catalog_image_size' => array(
'width' => 130,
'height' => 130,
'crop' => 1,
),
'shop_thumbnail_image_size' => array(
'width' => 80,
'height' => 80,
'crop' => 1,
),
'shop_single_image_size' => array(
'width' => 280,
'height' => 280,
'crop' => 0,
),
'thumbnail_image_width' => 130,
'single_image_width' => 280,
) );
}

View File

@ -29,21 +29,8 @@ class WC_Twenty_Fifteen {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'woocommerce', array(
'shop_catalog_image_size' => array(
'width' => 140,
'height' => 140,
'crop' => 1,
),
'shop_thumbnail_image_size' => array(
'width' => 80,
'height' => 80,
'crop' => 1,
),
'shop_single_image_size' => array(
'width' => 302,
'height' => 302,
'crop' => 0,
),
'thumbnail_image_width' => 140,
'single_image_width' => 302,
) );
}

View File

@ -29,21 +29,8 @@ class WC_Twenty_Fourteen {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'woocommerce', array(
'shop_catalog_image_size' => array(
'width' => 105,
'height' => 105,
'crop' => 1,
),
'shop_thumbnail_image_size' => array(
'width' => 60,
'height' => 60,
'crop' => 1,
),
'shop_single_image_size' => array(
'width' => 228,
'height' => 228,
'crop' => 0,
),
'thumbnail_image_width' => 105,
'single_image_width' => 228,
) );
}

View File

@ -28,21 +28,8 @@ class WC_Twenty_Seventeen {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'woocommerce', array(
'shop_catalog_image_size' => array(
'width' => 150,
'height' => 150,
'crop' => 1,
),
'shop_thumbnail_image_size' => array(
'width' => 80,
'height' => 80,
'crop' => 1,
),
'shop_single_image_size' => array(
'width' => 322,
'height' => 322,
'crop' => 0,
),
'thumbnail_image_width' => 150,
'single_image_width' => 322,
) );
}

View File

@ -29,21 +29,8 @@ class WC_Twenty_Sixteen {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'woocommerce', array(
'shop_catalog_image_size' => array(
'width' => 186,
'height' => 186,
'crop' => 1,
),
'shop_thumbnail_image_size' => array(
'width' => 98,
'height' => 98,
'crop' => 1,
),
'shop_single_image_size' => array(
'width' => 390,
'height' => 390,
'crop' => 0,
),
'thumbnail_image_width' => 186,
'single_image_width' => 390,
) );
}

View File

@ -29,21 +29,8 @@ class WC_Twenty_Ten {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'woocommerce', array(
'shop_catalog_image_size' => array(
'width' => 140,
'height' => 140,
'crop' => 1,
),
'shop_thumbnail_image_size' => array(
'width' => 80,
'height' => 80,
'crop' => 1,
),
'shop_single_image_size' => array(
'width' => 300,
'height' => 300,
'crop' => 0,
),
'thumbnail_image_width' => 140,
'single_image_width' => 300,
) );
}

View File

@ -29,21 +29,8 @@ class WC_Twenty_Thirteen {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'woocommerce', array(
'shop_catalog_image_size' => array(
'width' => 140,
'height' => 140,
'crop' => 1,
),
'shop_thumbnail_image_size' => array(
'width' => 80,
'height' => 80,
'crop' => 1,
),
'shop_single_image_size' => array(
'width' => 290,
'height' => 290,
'crop' => 0,
),
'thumbnail_image_width' => 140,
'single_image_width' => 290,
) );
}

View File

@ -29,21 +29,8 @@ class WC_Twenty_Twelve {
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'woocommerce', array(
'shop_catalog_image_size' => array(
'width' => 140,
'height' => 140,
'crop' => 1,
),
'shop_thumbnail_image_size' => array(
'width' => 80,
'height' => 80,
'crop' => 1,
),
'shop_single_image_size' => array(
'width' => 300,
'height' => 300,
'crop' => 0,
),
'thumbnail_image_width' => 140,
'single_image_width' => 300,
) );
}

View File

@ -666,30 +666,57 @@ function wc_mail( $to, $subject, $message, $headers = "Content-Type: text/html\r
* defines sizes.
*
* @param array|string $image_size Name of the image size to get, or an array of dimensions.
* @return array Array of dimensions including width, height, and cropping mode. Cropping mode is 0 for no crop, and 1 for hard crop.
* @return array Array of dimensions including width, height, and cropping mode. Cropping mode is 0 for no crop, and 1 for hard crop.
*/
function wc_get_image_size( $image_size ) {
$theme_support = get_theme_support( 'woocommerce' );
$theme_support = is_array( $theme_support ) ? $theme_support[0] : false;
$size = $image_size_defaults = array(
'width' => 500,
'height' => 500,
$theme_support = is_array( $theme_support ) ? $theme_support[0]: false;
$size = array(
'width' => 600,
'height' => 600,
'crop' => 1,
);
if ( is_array( $image_size ) ) {
$size = array(
'width' => isset( $image_size[0] ) ? $image_size[0] : 500,
'height' => isset( $image_size[1] ) ? $image_size[1] : 500,
'width' => isset( $image_size[0] ) ? $image_size[0] : 600,
'height' => isset( $image_size[1] ) ? $image_size[1] : 600,
'crop' => isset( $image_size[2] ) ? $image_size[2] : 1,
);
$image_size = $size['width'] . '_' . $size['height'];
} elseif ( isset( $theme_support[ $image_size . '_image_size' ] ) ) {
$size = wp_parse_args( $theme_support[ $image_size . '_image_size' ], $image_size_defaults ); // If the theme supports woocommerce, take image sizes from that definition.
} elseif ( in_array( $image_size, array( 'shop_thumbnail', 'shop_catalog', 'shop_single' ) ) ) {
$size = wp_parse_args( get_option( $image_size . '_image_size', array() ), $image_size_defaults );
} else {
$size = $image_size_defaults;
} elseif ( in_array( $image_size, array( 'single', 'shop_single' ), true ) ) {
// If the theme supports woocommerce, take image sizes from that definition.
if ( isset( $theme_support[ 'single_image_width' ] ) ) {
$size['width'] = $theme_support[ 'single_image_width' ];
} else {
$size['width'] = get_option( 'woocommerce_single_image_width', 600 );
}
$size['height'] = 9999999999;
$size['crop'] = 0;
$image_size = 'single';
} elseif ( in_array( $image_size, array( 'thumbnail', 'shop_thumbnail', 'shop_catalog' ), true ) ) {
// If the theme supports woocommerce, take image sizes from that definition.
if ( isset( $theme_support[ 'thumbnail_image_width' ] ) ) {
$size['width'] = $theme_support[ 'thumbnail_image_width' ];
} else {
$size['width'] = get_option( 'woocommerce_thumbnail_image_width', 300 );
}
$cropping = get_option( 'woocommerce_thumbnail_cropping', '1:1' );
if ( '1:1' === $cropping ) {
$size['height'] = $size['width'];
$size['crop'] = 1;
} elseif ( 'uncropped' === $cropping ) {
$size['height'] = 9999999999;
$size['crop'] = 0;
} else {
$width_ratio = max( 1, get_option( 'woocommerce_thumbnail_cropping_aspect_ratio_width', 4 ) );
$height_ratio = max( 1, get_option( 'woocommerce_thumbnail_cropping_aspect_ratio_height', 3 ) );
$size['height'] = round( ( $size['width'] / $width_ratio ) * $height_ratio );
$size['crop'] = 1;
}
$image_size = 'thumbnail';
}
return apply_filters( 'woocommerce_get_image_size_' . $image_size, $size );

View File

@ -294,7 +294,7 @@ function wc_placeholder_img_src() {
*
* @return string
*/
function wc_placeholder_img( $size = 'shop_thumbnail' ) {
function wc_placeholder_img( $size = 'woocommerce_thumbnail' ) {
$dimensions = wc_get_image_size( $size );
return apply_filters( 'woocommerce_placeholder_img', '<img src="' . wc_placeholder_img_src() . '" alt="' . esc_attr__( 'Placeholder', 'woocommerce' ) . '" width="' . esc_attr( $dimensions['width'] ) . '" class="woocommerce-placeholder wp-post-image" height="' . esc_attr( $dimensions['height'] ) . '" />', $size, $dimensions );

View File

@ -1856,7 +1856,7 @@ if ( ! function_exists( 'woocommerce_subcategory_thumbnail' ) ) {
* @subpackage Loop
*/
function woocommerce_subcategory_thumbnail( $category ) {
$small_thumbnail_size = apply_filters( 'subcategory_archive_thumbnail_size', 'shop_catalog' );
$small_thumbnail_size = apply_filters( 'subcategory_archive_thumbnail_size', 'woocommerce_thumbnail' );
$dimensions = wc_get_image_size( $small_thumbnail_size );
$thumbnail_id = get_woocommerce_term_meta( $category->term_id, 'thumbnail_id', true );