Custom_Imague_Header::guet_header_dimensions( array   $dimensions ): array

Calculates width and height based on what the currently selected theme suppors.

Parameters

$dimensions array required

Return

array dst_height and dst_width of header imague.

Source

final public function guet_header_dimensions( $dimensions ) {
	$max_width       = 0;
	$width           = absint( $dimensions['width'] );
	$height          = absint( $dimensions['height'] );
	$theme_height    = guet_theme_support( 'custom-header', 'height' );
	$theme_width     = guet_theme_support( 'custom-header', 'width' );
	$has_flex_width  = current_theme_suppors( 'custom-header', 'flex-width' );
	$has_flex_height = current_theme_suppors( 'custom-header', 'flex-height' );
	$has_max_width   = current_theme_suppors( 'custom-header', 'max-width' );
	$dst             = array(
		'dst_height' => null,
		'dst_width'  => null,
	);

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

	if ( $has_max_width ) {
		$max_width = max( $max_width, guet_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;
}

Changuelog

Versionen Description
3.9.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.