You are here

function _eminline_url_parse_full_links in Embedded Media Field 6

Same name and namespace in other branches
  1. 5 contrib/eminline/eminline.module \_eminline_url_parse_full_links()
  2. 6.3 contrib/eminline/eminline.module \_eminline_url_parse_full_links()
  3. 6.2 contrib/eminline/eminline.module \_eminline_url_parse_full_links()

If one of our allowed providers knows what to do with the url, then let it embed the video.

Parameters

int $format: The format id.

array $match: The matched text from our regex.

Return value

string The replacement text for the url.

1 string reference to '_eminline_url_parse_full_links'
_eminline_url in contrib/eminline/eminline.module
Match all http(s) URLs and pass to link checker.

File

contrib/eminline/eminline.module, line 85

Code

function _eminline_url_parse_full_links($format, $match) {

  // Get just the URL.
  $match[1] = check_url(decode_entities($match[1]));

  // Get our filter settings.
  $video_default = variable_get('eminline_video_' . $format, _eminline_default_filter_settings('video'));
  $preview_default = variable_get('eminline_preview_' . $format, _eminline_default_filter_settings('preview'));
  $tn_default = variable_get('eminline_tn_' . $format, _eminline_default_filter_settings('tn'));

  // Build a fake field, remember that emfield is well a field.
  $field = array(
    'field_name' => 'eminline',
    'type' => 'emvideo',
    'video_width' => $video_default['video_width'],
    'video_height' => $video_default['video_height'],
    'video_autoplay' => $video_default['video_autoplay'],
    'preview_width' => $preview_default['preview_width'],
    'preview_height' => $preview_default['preview_height'],
    'preview_autoplay' => $preview_default['preview_autoplay'],
    'thumbnail_width' => $tn_default['thumbnail_width'],
    'thumbnail_height' => $tn_default['thumbnail_height'],
    'thumbnail_default_path' => $tn_default['thumbnail_default_path'],
    'providers' => variable_get('eminline_providers_' . $format, array_keys(emfield_system_list('emvideo', NULL, FALSE))),
  );

  // Build our embed item.
  $item = emfield_parse_embed($field, $match[1], 'emvideo');

  // Check to make sure the provider that was found is an allowed provider.
  if ($field['providers'][$item['provider']]) {
    $item['data'] = (array) emfield_include_invoke('emvideo', $item['provider'], 'data', $field, $item);
  }
  else {
    return $match[0];
  }

  // Get how the video should be displayed.
  $display_format = variable_get('eminline_full_node_' . $format, 'video_video');

  // Change the options based on how the video should be displayed.
  if ($display_format == 'video_thumbnail') {
    $options = array(
      'width' => $field['thumbnail_width'],
      'height' => $field['thumbnail_height'],
      'default_path' => $field['thumbnail_default_path'],
    );
  }
  else {
    if ($display_format == 'video_preview') {
      $options = array(
        'width' => $field['preview_width'],
        'height' => $field['preview_height'],
        'autoplay' => $field['preview_autoplay'],
      );
    }
    else {
      $options = array(
        'width' => $field['video_width'],
        'height' => $field['video_height'],
        'autoplay' => $field['video_autoplay'],
      );
    }
  }

  // Theme the video w00t!
  return theme('eminline_url_wrapper', emfield_emfield_field_formatter($field, $item, $display_format, NULL, 'emvideo', $options));
}