You are here

function insert_shadowbox_insert_content in Shadowbox 7.4

Same name and namespace in other branches
  1. 8 insert_shadowbox/insert_shadowbox.module \insert_shadowbox_insert_content()

File

insert_shadowbox/insert_shadowbox.module, line 22

Code

function insert_shadowbox_insert_content($item, $style, $widget) {
  $style_name = preg_replace('/^shadowbox_/', '', $style['name']);
  $rel = "shadowbox";
  $path = INSERT_SHADOWBOX_ICOPATH . 'generic.png';
  $class = 'sb-insert sb-image sb-individual';
  switch ($widget['type']) {
    case 'image_image':
      $path = $item['uri'];
      $alt = isset($item['alt']) ? $item['alt'] : "";
      $title = isset($item['title']) ? $item['title'] : "";
      $class = 'image-' . $style_name . ' sb-insert sb-image sb-individual';
      break;
    case 'file_generic':
      $title = isset($item['description']) ? $item['description'] : '';
      $alt = $title;
      $width = variable_get('shadowbox_video_width', 640);
      $height = variable_get('shadowbox_video_height', 360);
      switch ($item['filemime']) {
        case 'video/mp4':
        case 'video/x-flv':
          $path = INSERT_SHADOWBOX_ICOPATH . 'flv.png';
          $style_name = '';
          $rel = 'shadowbox; player=flv; width=' . $width . '; height=' . $height;
          break;
        case 'video/quicktime':
          $path = INSERT_SHADOWBOX_ICOPATH . 'mov.png';
          $style_name = '';
          $rel = 'shadowbox; player=flv; width=' . $width . '; height=' . $height;
          break;
        case 'application/x-shockwave-flash':
          $path = INSERT_SHADOWBOX_ICOPATH . 'swf.png';
          $style_name = '';
          $rel = 'shadowbox; player=swf; width=' . $width . '; height=' . $height;
          break;
        default:
          if (strstr($item['filemime'], 'image/')) {
            $path = $item['uri'];
          }
          else {
            $style_name = '';
            $rel = '';
          }
      }
      break;
    default:
      break;
  }
  $image = array(
    'path' => $path,
    'alt' => $alt,
    'title' => $title,
    'image_style' => $style_name,
  );
  return theme('shadowbox_formatter', array(
    'innerHTML' => theme('shadowbox_thumbnail', $image),
    'title' => $title,
    'url' => file_create_url($item['uri']),
    'rel' => $rel,
    'class' => 'sb-insert sb-image sb-individual',
  ));
}