You are here

function _media_url_parse_full_links in D7 Media 7

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

Parameters

int $filter: The filter id.

array $match: The matched text from our regex.

Return value

string The replacement text for the url.

1 string reference to '_media_url_parse_full_links'
media_url_filter in includes/media.filter.inc
Filter callback for media url filter. @TODO: There are currently problems with this. For instance, if a file is to be loaded from a remote location here, it will be recreated multiple times, each time this filter is called. If we want to continue…

File

includes/media.filter.inc, line 251
Functions related to the WYSIWYG editor and the media input filter.

Code

function _media_url_parse_full_links($match) {

  // Get just the URL.
  $match[2] = check_url(decode_entities($match[2]));
  try {
    $file = media_parse_to_file($match[2]);
  } catch (Exception $e) {

    // Ignore errors; pass the original text for other filters to deal with.
    return $match[0];
  }
  if ($file->fid) {
    $file = file_load($file->fid);

    // Generate a preview of the file
    // @TODO: Allow user to change the formatter in the filter settings.
    $preview = file_view_file($file, 'media_large');
    $preview['#show_names'] = TRUE;
    return drupal_render($preview);
  }

  // Nothing was parsed; return the original text.
  return $match[0];
}