function youtube_get_dimensions in YouTube Field 8
Same name and namespace in other branches
- 7 youtube.inc \youtube_get_dimensions()
Splits height and width when given size, as from youtube_size_options.
Parameters
string $size: Image size.
string $width: Image width.
string $height: Image height.
Return value
array An array containing the dimensions.
1 call to youtube_get_dimensions()
- template_preprocess_youtube_video in ./
youtube.module - Prepares variables for the YouTube Video template.
File
- ./
youtube.module, line 280 - Youtube field module adds a field for YouTube videos.
Code
function youtube_get_dimensions($size = NULL, $width = NULL, $height = NULL) {
$dimensions = [];
if ($size == 'custom') {
$dimensions['width'] = (int) $width;
$dimensions['height'] = (int) $height;
}
else {
// Locate the 'x'.
$strpos = strpos($size, 'x');
// Width is the first dimension.
$dimensions['width'] = substr($size, 0, $strpos);
// Height is the second dimension.
$dimensions['height'] = substr($size, $strpos + 1, strlen($size));
}
return $dimensions;
}