You are here

function oembed_resolve_link in oEmbed 7.0

Same name and namespace in other branches
  1. 7 oembed.filter.inc \oembed_resolve_link()

PREG replace callback finds [embed] shortcodes, URLs and request options.

See also

MediaInternetOEmbedHandler::preSave().

2 calls to oembed_resolve_link()
oembed_preg_tag_replace in ./oembed.filter.inc
PREG replace callback finds [embed] shortcodes, URLs and request options.
_oembed_resolve_link in ./oembed_legacy.inc

File

./oembed.filter.inc, line 183
Input filter that enhances oEmbed enabled URLs with extra content

Code

function oembed_resolve_link($url, $view_mode = 'full', $options = array()) {
  $url = decode_entities($url);
  $element = array();
  $matches = array();

  // If file_entity module is enabled, treat the URL as an uploaded file.
  if (module_exists('file_entity')) {
    $file = oembed_url_to_file($url);
    $file->override = $options;
    if (isset($file->fid)) {
      $element = file_view($file, $view_mode);
    }
  }
  else {
    if ($provider = oembed_get_provider($url, $matches)) {
      $embed = oembed_get_data($url);
      if ($embed) {
        $element = oembed_render_element('oembed', $url, $options);
      }
    }
  }
  $return = drupal_render($element);
  if (empty($return)) {
    $return = $url;
  }
  return $return;
}