You are here

function asset_youtube_asset_formatter in Asset 6

Same name and namespace in other branches
  1. 5 asset_youtube/asset_youtube.module \asset_youtube_asset_formatter()

File

asset_youtube/asset_youtube.module, line 152

Code

function asset_youtube_asset_formatter($op = 'info', $asset = null, $attr = array()) {
  switch ($op) {
    case 'info':
      $formats['video'] = array(
        'name' => 'YouTube Video',
        'types' => array(
          'youtube' => array(
            '*',
          ),
        ),
        'description' => t('Embed the YouTube video.'),
      );
      $formats['thumbnail'] = array(
        'name' => 'YouTube Thumbnail Image',
        'types' => array(
          'youtube' => array(
            '*',
          ),
        ),
        'description' => t('Display a thumbnail preview image of the YouTube video.'),
      );
      return $formats;
    case 'init':
      break;
    case 'options':
      switch ($attr['format']) {
        case 'thumbnail':
          break;
        case 'video':
          $form['height'] = array(
            '#type' => 'textfield',
            '#title' => t('Height'),
            '#size' => '10',
            '#default_value' => 325,
          );
          $form['width'] = array(
            '#type' => 'textfield',
            '#title' => t('Width'),
            '#size' => '10',
            '#default_value' => 450,
          );
          break;
      }
      return $form;
    case 'preview':
      return theme('asset_youtube_thumbnail', $asset);
    case 'img':
      $id = str_replace('.youtube', '', $asset->filename);
      $url = "http://img.youtube.com/vi/{$id}/2.jpg";
      return $url;
      break;
    case 'details':
      break;
    case 'render':
      switch ($attr['format']) {
        case 'thumbnail':
          return theme('asset_youtube_thumbnail', $asset);
          break;
        case 'video':
        default:
          return theme('asset_youtube_video', $asset, $attr);
          break;
      }
      break;
  }
}