You are here

function theme_emaudio_emaudio_thumbnail in Embedded Media Field 5

File

contrib/emaudio/emaudio.module, line 338

Code

function theme_emaudio_emaudio_thumbnail($field, $item, $formatter, $node, $options = array()) {
  if ($item['value'] && $item['provider']) {

    // if we have emthumb installed, then give it a chance to override our thumbnail
    $thumbnail_url = module_invoke('emthumb', 'thumbnail_url', $item);

    // if we don't have a custom thumbnail, then see if the provider gives us one
    $thumbnail_url = $thumbnail_url ? $thumbnail_url : module_invoke('emfield', 'include_invoke', 'emaudio', $item['provider'], 'thumbnail', $field, $item, $formatter, $node, $width, $height, $options);

    // if we still don't have a thumbnail, then apply a default thumbnail, if it exists
    if (!$thumbnail_url) {
      $default_thumbnail_url = $field['widget']['thumbnail_default_path'] ? $field['widget']['thumbnail_default_path'] : variable_get('emaudio_default_thumbnail_path', NULL);
      if ($default_thumbnail_url) {
        $thumbnail_url = base_path() . $default_thumbnail_url;
      }
    }
    if ($thumbnail_url) {
      $width = $field['widget']['thumbnail_width'] ? $field['widget']['thumbnail_width'] : variable_get('emaudio_default_thumbnail_width', EMAUDIO_DEFAULT_THUMBNAIL_WIDTH);
      $height = $field['widget']['thumbnail_height'] ? $field['widget']['thumbnail_height'] : variable_get('emaudio_default_thumbnail_height', EMAUDIO_DEFAULT_THUMBNAIL_HEIGHT);
      $output = l('<img src="' . $thumbnail_url . '" width="' . $width . '" height="' . $height . '" alt="' . t('Hear Audio') . '" title="' . t('Hear Audio') . '" />', 'node/' . $node->nid, array(), NULL, NULL, false, true);
    }
    else {

      // if all else fails, then just print a 'see audio' link.
      $output = l(t('Hear Audio'), 'node/' . $node->nid);
    }
  }
  return $output;
}