You are here

function _video_dimensions_options in Video 6.4

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

Function updates our options list to show matching aspect ratios and if we have a matching resolution.

We will update the options array by reference and return the aspect ratio of the file.

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

File

./video_widget.inc, line 144
Common widget functions

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)');
    }
    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)');
      }
    }
  }
  return $aspect_ratio;
}