diff --git a/README.txt b/README.txt index cee0629..89cf4d7 100644 --- a/README.txt +++ b/README.txt @@ -3,6 +3,9 @@ This is a highly flexible and easy extendable filter module to embed any type of video in your site using a simple tag. Other modules can add video sites/formats (called codecs) using an easy plug-in architecture. +The Fluidvids library may optionally be used to make the video player +responsive. + ========= Installation ========= Enable the module on the modules page. @@ -22,6 +25,14 @@ processed after that filter. To enable WYSIWYG support, go to the WYSIWYG settings for each input format and enable the Video Filter button. +To use the Fluidvids library, download a release from + https://github.com/toddmotto/fluidvids +into a directory at: + sites/all/libraries/fluidvids +so that the library is available from: + sites/all/libraries/fluidvids/fluidvids.js + + ========= Usage ========= Single video: [video:url] diff --git a/video_filter.module b/video_filter.module index a97615b..401be90 100644 --- a/video_filter.module +++ b/video_filter.module @@ -125,6 +125,17 @@ function _video_filter_process($text, $filter, $format, $langcode, $cache, $cach 'related' => $filter->settings['video_filter_related'], ); + // Detect default or 100% settings. + if (isset($matches_code[3], $matches_code[3][0]) && is_string($matches_code[3][0])) { + if ((strrpos($matches_code[3][0], 'width:100%') > 0) + || (strrpos($matches_code[3][0], 'height:100%') > 0) + || ((strrpos($matches_code[3][0], 'width:') === FALSE + && strrpos($matches_code[3][0], 'height:') === FALSE + ) { + $video['fluidvids'] = TRUE; + } + } + // Pick random out of multiple sources separated by comma (,). if (strstr($video['source'], ',')) { $sources = explode(',', $video['source']); @@ -361,6 +372,11 @@ function video_filter_get_classes($video) { $classes[] = 'video-' . $video['align']; } + // Add fluidvids class. + if (isset($video['fluidvids'])) { + $classes[] = 'video-fluidvids'; + } + // First match is the URL, we don't want that as a class. unset($video['codec']['matches'][0]); foreach ($video['codec']['matches'] as $match) { @@ -681,3 +697,13 @@ function video_filter_oembed_request($endpoint, array $arguments) { return FALSE; } } + +/** + * Implements hook_page_build(). + */ +function video_filter_page_build() { + if (file_exists('sites/all/libraries/fluidvids/fluidvids.js')) { + drupal_add_js('sites/all/libraries/fluidvids/fluidvids.js', array('type' => 'file', 'scope' => 'footer', 'weight' => 10)); + drupal_add_js('fluidvids.init({selector:[".video-fluidvids"]});', array('type' => 'inline', 'scope' => 'footer', 'weight' => 11)); + } +}