function _video_dimensions_options in Video 7.2
Same name and namespace in other branches
- 6.5 video_widget.inc \_video_dimensions_options()
- 6.4 video_widget.inc \_video_dimensions_options()
- 7 video.module \_video_dimensions_options()
Updates options list to show matching aspect ratios and matching resolutions
We will update the options array by reference and return the aspect ratio of the file.
1 call to _video_dimensions_options()
- video_field_widget_process in ./
video.field.inc - An element #process callback for the video field type.
File
- ./
video.field.inc, line 938 - Implement a video field, based on the file module's file field.
Code
function _video_dimensions_options(&$options, $video) {
$aspect_ratio = _video_aspect_ratio($video);
if (empty($aspect_ratio)) {
return $aspect_ratio;
}
// Loop through our options and find matching ratio's and also the exact width/height
foreach ($options as $key => $value) {
$wxh = explode('x', $value);
// Lets check our width and height first
if ($aspect_ratio['width'] == $wxh[0] && $aspect_ratio['height'] == $wxh[1]) {
$options[$key] = $value . ' (' . t('Matches resolution of original file') . ')';
}
else {
// Now lets check our ratio's
$ratio = number_format($wxh[0] / $wxh[1], 4);
if ($ratio == $aspect_ratio['ratio']) {
$options[$key] = $value . ' (' . t('Matches ratio of original file') . ')';
}
}
}
return $aspect_ratio;
}