Automattic\WooCommerce\Blocks\BlockTypes
ProductGallery::get_store_thumbnail_aspect_ratio
Get the store thumbnail aspect ratio from WooCommerce Customizer settings.
Метод класса: ProductGallery{}
Хуков нет.
Возвращает
string|null. CSS aspect ratio value, or null when uncropped.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_store_thumbnail_aspect_ratio();
Код ProductGallery::get_store_thumbnail_aspect_ratio() ProductGallery::get store thumbnail aspect ratio WC 11.1.2
private function get_store_thumbnail_aspect_ratio() {
$cropping = get_option( 'woocommerce_thumbnail_cropping', '1:1' );
if ( 'uncropped' === $cropping ) {
return null;
}
if ( 'custom' === $cropping ) {
$width = max( 1, (float) get_option( 'woocommerce_thumbnail_cropping_custom_width', '4' ) );
$height = max( 1, (float) get_option( 'woocommerce_thumbnail_cropping_custom_height', '3' ) );
return $width . '/' . $height;
}
return str_replace( ':', '/', $cropping );
}