Helper::calculate_player_height( string $aspect_ratio, int $width, bool|float $ratio = false )

Calculate player height from given aspect ratio and width.


Parameters

$aspect_ratio

(Required) The aspect ratio used for the calculations.

$width

(Required) The video embed width.

$ratio

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

Default value: false


Return

(float) The player height.


Source

File: includes/libs/helper.class.php

	public static function calculate_player_height( $aspect_ratio, $width, $ratio =  false ){
		$width = absint($width);

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

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

		return $height;
	}

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!