You are here

function oembedinline_oembed_resolve_link in oEmbed 8

oEmbed filter replacement callback.

Override basic function by setting Drupal system variable `oembed_resolve_link_callback` to a new function name with this signature.

Parameters

string $url: URL to embed.

array $options: oEmbed request options.

Return value

string Rendered oEmbed response.

File

./oembed.api.php, line 60
Hooks provided by the oEmbed module.

Code

function oembedinline_oembed_resolve_link($url, $options = array()) {

  // If file_entity module is enabled, treat the URL as an uploaded file.
  // Inline is used to defer the rendering of the embedded content until the
  // entity is actually viewed. This technique allows content to be cached by
  // Drupal's filter system.
  $view_mode = 'full';
  if (isset($options['view_mode'])) {
    $view_mode = $options['view_mode'];
    unset($options['view_mode']);
  }
  $url = decode_entities($url);
  $element = array();
  $file = oembed_url_to_file($url);
  $file->override = $options;
  if (isset($file->fid)) {
    $macro_params = array();
    $macro_params[] = 'entity';
    $macro_params[] = 'type=file';
    $macro_params[] = 'id=' . $file->fid;
    $macro_params[] = 'view_mode=' . $view_mode;
    $element = array(
      '#markup' => "\r\n" . '[' . implode('|', $macro_params) . ']' . "\r\n",
    );
  }
  $return = drupal_render($element);
  if (empty($return)) {
    $return = $url;
  }
  return $return;
}