Helper::calculate_player_width( string $aspect_ratio, int $height, bool|float $ratio = false )

Calculates player width based on the player height.


Parameters

$aspect_ratio

(Required) The aspect ratio used for the calculations.

$height

(Required) The player height.

$ratio

(Optional) A given ratio that will override aspect ratio if set.

Default value: false


Return

(float) The player width.


Source

File: includes/libs/helper.class.php

	public static function calculate_player_width( $aspect_ratio, $height, $ratio = false ){
		$height = absint( $height );

		$override = Plugin::instance()->get_embed_options_obj()
		                  ->get_option('aspect_override');

		if( !is_wp_error( $override ) && $override && is_numeric( $ratio ) && $ratio > 0 ){
			$width = floor( $height * $ratio );
		}else{
			switch( $aspect_ratio ){
				case '4x3':
					$width = floor( ($height * 4) / 3 );
					break;
				case '16x9':
				default:
				$width = floor( ($height * 16) / 9 );
					break;
				case '2.35x1':
					$width = floor( $height * 2.35 );
					break;
			}
		}

		return $width;
	}

Start your video site now!

Manage and coordinate your Vimeo channels, albums or videos with your WordPress website. Perfect fit for membership, portfolio, online courses or any type of video collection.

Get Vimeotheque PRO!