diff --git a/README.txt b/README.txt index e6958da..a470f08 100644 --- a/README.txt +++ b/README.txt @@ -76,7 +76,7 @@ function MODULE_youtube($video) { // $video contains the video URL in source, the codec (as above) and also // [code][matches] with the result of the regexp and [codec][delta] with the // key of the matched regexp. - $video['source'] = 'http://www.youtube.com/v/' . $video['codec']['matches'][1] . ($video['autoplay'] ? '&autoplay=1' : ''); + $video['source'] = '//www.youtube.com/v/' . $video['codec']['matches'][1] . ($video['autoplay'] ? '&autoplay=1' : ''); // Outputs a general for embedding flash players. Needs width, // height, source and optionally align (left or right) and params (a list of diff --git a/video_filter.codecs.inc b/video_filter.codecs.inc index 401991f..11c38e5 100644 --- a/video_filter.codecs.inc +++ b/video_filter.codecs.inc @@ -610,12 +610,23 @@ function video_filter_youku_html5($video) { */ function video_filter_youtube($video) { $attributes = array( - 'rel' => $video['related'] ? 'rel=1' : 'rel=0', - 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0', + 'modestbranding' => !empty($video['modestbranding']) ? 'modestbranding=1' : 'modestbranding=0', + 'rel' => !empty($video['related']) ? 'rel=1' : 'rel=0', + 'autoplay' => !empty($video['autoplay']) ? 'autoplay=1' : 'autoplay=0', 'fs' => 'fs=1', + 'loop' => !empty($video['loop']) ? 'loop=1' : 'loop=0', + 'controls' => !empty($video['controls']) ? 'controls=1' : 'controls=0', + 'autohide' => !empty($video['autohide']) ? 'autohide=1' : 'autohide=0', + 'showinfo' => !empty($video['showinfo']) ? 'showinfo=1' : 'showinfo=0', + 'theme' => !empty($video['theme']) ? 'theme=' . $video['theme'] : 'theme=dark', + 'color' => !empty($video['color']) ? 'color=' . $video['color'] : 'color=red', ); - $video['source'] = '//www.youtube.com/v/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); + if (!empty($video['loop'])) { + $attributes['playlist'] = 'playlist=' . $video['codec']['matches'][1]; + } + + $video['source'] = '//www.youtube.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); $params['wmode'] = 'opaque'; @@ -640,11 +651,23 @@ function video_filter_vine($video) { */ function video_filter_youtube_html5($video) { $attributes = array( + 'modestbranding' => !empty($video['modestbranding']) ? 'modestbranding=1' : 'modestbranding=0', 'html5' => 'html5=1', 'rel' => $video['related'] ? 'rel=1' : 'rel=0', 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0', 'wmode' => 'wmode=opaque', + 'loop' => !empty($video['loop']) ? 'loop=1' : 'loop=0', + 'controls' => !empty($video['controls']) ? 'controls=1' : 'controls=0', + 'autohide' => !empty($video['autohide']) ? 'autohide=1' : 'autohide=0', + 'showinfo' => !empty($video['showinfo']) ? 'showinfo=1' : 'showinfo=0', + 'theme' => !empty($video['theme']) ? 'theme=' . $video['theme'] : 'theme=dark', + 'color' => !empty($video['color']) ? 'color=' . $video['color'] : 'color=red', ); + + if (!empty($video['loop'])) { + $attributes['playlist'] = 'playlist=' . $video['codec']['matches'][1]; + } + $video['source'] = '//www.youtube.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes); return video_filter_iframe($video); diff --git a/video_filter.module b/video_filter.module index 7e5bb29..5a0ecf3 100644 --- a/video_filter.module +++ b/video_filter.module @@ -217,11 +217,21 @@ function _video_filter_process($text, $filter, $format, $langcode, $cache, $cach // Sets video width & height after any user input has been parsed. // First, check if user has set a width. if (isset($video['width']) && !isset($video['height'])) { - $video['height'] = $filter->settings['video_filter_height']; + if ($ratio) { + $video['height'] = ceil($video['width'] / $ratio); + } + else { + $video['height'] = $filter->settings['video_filter_height']; + } } // Else, if user has set height. elseif (isset($video['height']) && !isset($video['width'])) { - $video['width'] = $video['height'] * $ratio; + if ($ratio) { + $video['width'] = ceil($video['height'] * $ratio); + } + else { + $video['width'] = $filter->settings['video_filter_height']; + } } // Maybe both? elseif (isset($video['height']) && isset($video['width'])) { @@ -244,16 +254,7 @@ function _video_filter_process($text, $filter, $format, $langcode, $cache, $cach // Respect setting provided by codec otherwise. $control_bar_height = $video['codec']['control_bar_height']; } - - // Resize to fit within width and height repecting aspect ratio. - if ($ratio) { - $scale_factor = min(array( - ($video['height'] - $control_bar_height), - $video['width'] / $ratio, - )); - $video['height'] = round($scale_factor + $control_bar_height); - $video['width'] = round($scale_factor * $ratio); - } + $video['height'] += $control_bar_height; $video['autoplay'] = (bool) $video['autoplay']; $video['align'] = (isset($video['align']) && in_array($video['align'], array(