You are here

function _itweak_upload_get_link_options in iTweak Upload 6.2

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

Parameters

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

$setting_name: Setting name (inner part of whole name). Used to construct whole setting name.

$node_type: Node type name. Used to construct whole setting name.

$group: Group name for handler grouping option

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

2 calls to _itweak_upload_get_link_options()
_itweak_upload_files_thumbnails in ./itweak_upload.module
Similar to _itweak_upload_preprocess_files(), only works on already prepared form
_itweak_upload_preprocess_files in ./itweak_upload.module
Worker function for preprocessing node & comment files.

File

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

Code

function _itweak_upload_get_link_options($file, $setting_name, $node_type, $group) {
  $href = _itweak_upload_file_create_url($file);
  $text = $file->description ? $file->description : $file->filename;
  $options = array();
  $link_option = _itweak_upload_get_setting('thumbnail_link', $setting_name, $node_type, _itweak_upload_setting_link_default());
  $handler = '';
  if (module_exists('lightbox2')) {
    switch ($link_option) {
      case 'lightbox2':
        $handler = 'lightbox';
        $handler .= '[<a href="' . $href . '">' . $text . '</a>]';
        $options['attributes'] = array(
          'rel' => $handler,
        );
        break;
      case 'lightbox2grouped':
        $handler = 'lightbox' . ($group ? '[attachment-thumb-' . $group . ']' : '[attachment-thumb]');
        $handler .= '[<a href="' . $href . '">' . $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_option) {
      case 'colorbox':
        $handler = $group ? 'node_' . $group : 'node';
        $options['attributes'] = array(
          'class' => 'colorbox',
          'rel' => $handler,
        );
        break;
    }
  }
  if (module_exists('thickbox')) {
    switch ($link_option) {
      case 'thickbox':
        $handler = $group ? 'node_' . $group : 'node';
        $options['attributes'] = array(
          'class' => 'thickbox',
          'rel' => $handler,
        );
        break;
    }
  }
  if (module_exists('fancybox')) {
    switch ($link_option) {
      case 'fancybox':
        $handler = $group ? 'node_' . $group : 'node';
        $options['attributes'] = array(
          'class' => 'fancybox',
          'rel' => $handler,
        );
        break;
    }
  }
  if (module_exists('shadowbox')) {
    switch ($link_option) {
      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')) {
    switch ($link_option) {
      case 'highslide':

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