function _video_aspect_ratio in Video 7.2
Same name and namespace in other branches
- 6.5 video.module \_video_aspect_ratio()
- 6.4 video.module \_video_aspect_ratio()
- 7 video.module \_video_aspect_ratio()
Returns the width/height and aspect ratio of the video
2 calls to _video_aspect_ratio()
- video_field_widget_value in ./
video.field.inc - The #value_callback for the video field element.
- _video_dimensions_options in ./
video.field.inc - Updates options list to show matching aspect ratios and matching resolutions
File
- ./
video.field.inc, line 967 - Implement a video field, based on the file module's file field.
Code
function _video_aspect_ratio($video) {
$transcoder = new Transcoder();
$transcoder = $transcoder
->getTranscoder();
$transcoder
->setInput((array) $video);
$wxh = $transcoder
->getDimensions();
if (empty($wxh) || empty($wxh['width']) || empty($wxh['height'])) {
// No width and height found. This may be because the transcoder does not support retrieving dimensions.
return NULL;
}
return array(
'width' => $wxh['width'],
'height' => $wxh['height'],
'ratio' => number_format($wxh['width'] / $wxh['height'], 4),
);
}