You are here

function _video_dimensions_options in Video 6.5

Same name and namespace in other branches
  1. 6.4 video_widget.inc \_video_dimensions_options()
  2. 7.2 video.field.inc \_video_dimensions_options()
  3. 7 video.module \_video_dimensions_options()

Updates options list to show matching aspect ratios and resolutions

We will update the options array by reference and return the dimensions of the video.

1 call to _video_dimensions_options()
video_widget_element_settings in ./video_widget.inc
Process elements loads on settings

File

./video_widget.inc, line 149
Common Video module widget functions

Code

function _video_dimensions_options(&$options, $video) {
  $transcoder = video_get_transcoder();
  $dimensions = $transcoder
    ->get_dimensions($video);
  if (empty($dimensions)) {
    return $dimensions;
  }
  $videoratio = _video_aspect_ratio($dimensions['width'], $dimensions['height']);

  // 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 ($videoratio['width'] == $wxh[0] && $videoratio['height'] == $wxh[1]) {
      $options[$key] = $value . ' ' . t('(Matches Resolution)');
    }
    else {

      // Now lets check our ratio's
      $ratio = _video_aspect_ratio($wxh[0], $wxh[1]);
      if ($ratio == $videoratio) {
        $options[$key] = $value . ' ' . t('(Matches Ratio)');
      }
    }
  }
  return $dimensions;
}