You are here

function _itweak_upload_lightbox_get_link_options in iTweak Upload 7.3

Retrieve link options - carries handler setting for link display mode.

Parameters

$file: File object, same type as nodeapi 'view'

$display: $display parameter from hook_field_formatter_view().

$entity_type: $entity_type parameter from hook_field_formatter_view().

$entity: $entity parameter from hook_field_formatter_view().

Return value

Options array for the thumbnail link l()

The following variables can be defined to select thumbnail link handler: 'none' if none of the settings are defined itweak_upload_thumbnail_link_default - Site-wide default itweak_upload_thumbnail_link_default_$type + Default for all thumbnails in content $type itweak_upload_thumbnail_link_node_$type - Regular attachments thumbnails itweak_upload_thumbnail_link_images_teaser_$type - Gallery images in teaser view itweak_upload_thumbnail_link_images_node_$type - Gallery images in node view itweak_upload_thumbnail_link_comment_$type - Regular comment attachments thumbnails itweak_upload_thumbnail_link_comment_images - Gallery images in comment Where: + means that the setting is already implemented in GUI

See also

_itweak_upload_get_link_options() in D6

1 call to _itweak_upload_lightbox_get_link_options()
_itweak_upload_preprocess_files in ./itweak_upload.module
Worker function for preprocessing filefield files.

File

./itweak_upload.module, line 828
iTweakUpload - Tweak attachments display and file upload forms.

Code

function _itweak_upload_lightbox_get_link_options($file, $display, $entity_type, $entity) {
  $settings = $display['settings'];
  $url = empty($file->path) ? file_create_url($file->uri) : $file->path;
  $group = _itweak_upload_group_id($entity_type, $entity);
  $link_text = $text = !empty($file->description) ? $file->description : $file->filename;
  $options = array();
  $link_mode = $settings['image_link_mode'];
  $handler = '';
  if (module_exists('lightbox2')) {
    switch ($link_mode) {
      case 'lightbox2':
        $handler = 'lightbox';
        $handler .= '[<a href="' . $url . '">' . $text . '</a>]';
        $options['attributes'] = array(
          'rel' => $handler,
        );
        break;
      case 'lightbox2grouped':
        $handler = 'lightbox' . ($group ? '[attachment-thumb-' . $group . ']' : '[attachment-thumb]');
        $handler .= '[<a href="' . $url . '">' . $text . '</a>]';
        $options['attributes'] = array(
          'rel' => $handler,
        );
        break;
      case 'lightbox2slideshow':
        $handler = 'lightshow' . ($group ? '[attachment-thumb-' . $group . ']' : '[attachment-thumb]');
        $options['attributes'] = array(
          'rel' => $handler,
        );
        break;
    }
  }
  if (module_exists('colorbox')) {
    switch ($link_mode) {
      case 'colorbox':
        $handler = $group ? 'node_' . $group : 'node';
        $options['attributes'] = array(
          'class' => 'colorbox',
          'rel' => $handler,
        );
        break;
    }
  }
  if (module_exists('fancybox')) {
    switch ($link_mode) {
      case 'fancybox':
        $handler = $group ? 'node_' . $group : 'node';
        $options['attributes'] = array(
          'class' => 'fancybox',
          'rel' => $handler,
        );
        break;
    }
  }
  if (module_exists('shadowbox')) {
    switch ($link_mode) {
      case 'shadowbox':

        //        $handler = ($group ? 'node_' . $group : 'node');
        $handler = 'shadowbox';
        $options['attributes'] = array(
          'class' => 'shadowbox',
          'rel' => $handler,
        );
        break;
      case 'shadowboxgrouped':
        $handler = 'shadowbox' . ($group ? '[' . $group . ']' : '');
        $options['attributes'] = array(
          'class' => 'shadowbox',
          'rel' => $handler,
        );
        break;
    }
  }
  if (module_exists('highslide') || module_exists('highslide2')) {
    switch ($link_mode) {
      case 'highslide':

        //?        $handler = ($group ? $group : 'node');
        $options['attributes'] = array(
          'class' => 'highslide',
          'onclick' => 'return hs.expand(this)',
        );
        break;
      case 'highslidegrouped':
        $handler = $group ? $group : 'node';
        $options['attributes'] = array(
          'class' => 'Ahighslide',
          'onclick' => 'return hs.expand(this, { slideshowGroup: \'' . $handler . '\' });',
        );
        break;
    }
  }
  $options['link_mode'] = $link_mode;
  _itweak_upload_lightbox_load($options);
  unset($options['link_mode']);
  return $options;
}