diff --git a/video_filter.module b/video_filter.module index 248bc37..e1144f7 100644 --- a/video_filter.module +++ b/video_filter.module @@ -125,6 +125,20 @@ 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]) && isset($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 +375,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 +700,13 @@ function video_filter_oembed_request($endpoint, array $arguments) { return FALSE; } } + +/** + * Implements hook_init(). + */ +function video_filter_init() { + 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)); + } +}