WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

Custom_Image_Header::get_header_dimensions() public WP 3.9.0

Calculate width and height based on what the currently selected theme supports.

Это метод класса: Custom_Image_Header{}

Хуков нет.

Возвращает

Массив. dst_height and dst_width of header image.

Использование

$Custom_Image_Header = new Custom_Image_Header();
$Custom_Image_Header->get_header_dimensions( $dimensions );
$dimensions(массив) (обязательный)

Список изменений

С версии 3.9.0 Введена.

Код Custom_Image_Header::get_header_dimensions() WP 5.5.1

wp-admin/includes/class-custom-image-header.php
<?php
final public function get_header_dimensions( $dimensions ) {
	$max_width       = 0;
	$width           = absint( $dimensions['width'] );
	$height          = absint( $dimensions['height'] );
	$theme_height    = get_theme_support( 'custom-header', 'height' );
	$theme_width     = get_theme_support( 'custom-header', 'width' );
	$has_flex_width  = current_theme_supports( 'custom-header', 'flex-width' );
	$has_flex_height = current_theme_supports( 'custom-header', 'flex-height' );
	$has_max_width   = current_theme_supports( 'custom-header', 'max-width' );
	$dst             = array(
		'dst_height' => null,
		'dst_width'  => null,
	);

	// For flex, limit size of image displayed to 1500px unless theme says otherwise.
	if ( $has_flex_width ) {
		$max_width = 1500;
	}

	if ( $has_max_width ) {
		$max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) );
	}
	$max_width = max( $max_width, $theme_width );

	if ( $has_flex_height && ( ! $has_flex_width || $width > $max_width ) ) {
		$dst['dst_height'] = absint( $height * ( $max_width / $width ) );
	} elseif ( $has_flex_height && $has_flex_width ) {
		$dst['dst_height'] = $height;
	} else {
		$dst['dst_height'] = $theme_height;
	}

	if ( $has_flex_width && ( ! $has_flex_height || $width > $max_width ) ) {
		$dst['dst_width'] = absint( $width * ( $max_width / $width ) );
	} elseif ( $has_flex_width && $has_flex_height ) {
		$dst['dst_width'] = $width;
	} else {
		$dst['dst_width'] = $theme_width;
	}

	return $dst;
}