You are here

function oembedcore_oembed_html in oEmbed 6.0

To be used for HTML in cases where the HTML is cached independent of the theme - like in the case of input filters.

1 call to oembedcore_oembed_html()
_oembed_resolve_link in ./oembed.inc

File

./oembedcore.module, line 329
Core functionality for oEmbed

Code

function oembedcore_oembed_html($embed, $url) {

  //TODO: Maybe refactor into something that uses drupal_render()?
  $return = '';
  switch ($embed->type) {
    case 'photo':
      $return = '<span class="oembed">';
      if (!empty($embed->title)) {
        $return .= l($embed->title, $url, array(
          'absolute' => TRUE,
          'attributes' => array(
            'class' => 'oembed-title',
          ),
        ));
      }
      $img_attributes = array(
        'src' => check_url($embed->url),
        'alt' => empty($embed->title) ? t('Embedded image') : $embed->title,
      );
      if (!empty($embed->provider_name)) {
        $img_attributes['alt'] .= ', ' . t('on') . ' ' . $embed->provider_name;
      }
      $return .= ' ' . l('<img' . drupal_attributes($img_attributes) . ' />', $url, array(
        'html' => TRUE,
        'absolute' => TRUE,
        'attributes' => array(
          'class' => 'oembed-photo oembed-content',
        ),
      ));
      $return .= '</span>';
      break;
    case 'rich':
    case 'video':
      $return = '<div class="oembed">';
      if (!empty($embed->title)) {
        $return .= l($embed->title, $url, array(
          'absolute' => TRUE,
          'attributes' => array(
            'class' => 'oembed-title',
          ),
        ));
      }
      $return .= ' <span class="oembed-content oembed-' . ($embed->type == 'video' ? 'video' : 'rich') . '">' . $embed->html . '</span>';
      $return .= '</div>';
      break;
    case 'link':
      $return .= l($embed->title, $url, array(
        'absolute' => TRUE,
        'attributes' => array(
          'class' => 'oembed-title oembed-link',
        ),
      ));
      break;
    default:
  }
  return $return;
}