You are here

function theme_node_gallery_formatter_nextimagelink in Node Gallery 6.3

Node gallery formatter hooks and callbacks.

1 string reference to 'theme_node_gallery_formatter_nextimagelink'
node_gallery_theme in ./node_gallery.module
Implements hook_theme().

File

theme/theme.inc, line 190
Node gallery theme functions

Code

function theme_node_gallery_formatter_nextimagelink($element) {

  // Inside a view $element may contain null data. In that case, just return.
  if (empty($element['#item']['fid'])) {
    return '';
  }

  // If node type is not in a gallery relationship or gid is not set, just render the default formatter.
  $imagetag = theme_imagecache_formatter_default($element);
  $node = $element['#node'];
  if (!in_array($node->type, (array) node_gallery_get_types('image')) || !isset($node->gid)) {
    return $imagetag;
  }
  $relationship = node_gallery_get_relationship(NULL, $node->type);
  $next = node_gallery_get_next_image($node->gid, $node->nid);
  if ($next !== NULL) {
    $class = 'imagefield image-nextimagelink imagefield-' . $element['#field_name'];
    $options = array(
      'attributes' => array(
        'class' => $class,
      ),
      'html' => TRUE,
    );
    if ($relationship['settings']['node_images_page_fragment']) {
      $options['fragment'] = 'node-' . $next;
    }
    return l($imagetag, 'node/' . $next, $options);
  }
  else {

    // no link on the last image
    return $imagetag;
  }
}