You are here

function node_gallery_get_image_position in Node Gallery 6.3

Returns the position (starting at one) of the image in the gallery list.

Parameters

$gid: The nid of the gallery to use.

$nid: The nid of the image to return the position of.

Return value

The position of the image in the list of published images in the gallery.

4 calls to node_gallery_get_image_position()
node_gallery_get_images_slice in ./node_gallery.inc
Returns a specific slice of the node_gallery_get_images() array. If both $to_left and $to_right are not set or are 0, this returns only 1 element.
node_gallery_get_image_navigator in ./node_gallery.inc
Builds an array with the data necessary to navigate a gallery.
node_gallery_nodeapi in ./node_gallery.module
Implements hook_nodeapi().
node_gallery_seek_from_current_image in ./node_gallery.inc
Returns the nid of the image +/-N steps away from the current image node.

File

./node_gallery.inc, line 600
Shared functions for node_gallery

Code

function node_gallery_get_image_position($gid, $nid, $reset = FALSE) {
  static $image_position = array();
  if (!isset($image_position[$gid]) || $reset) {
    if (!$reset && ($cache = cache_get('node_gallery:' . $gid . ':image_position')) && !empty($cache->data)) {
      $image_position[$gid] = $cache->data;
    }
    else {
      _node_gallery_cache_sorted_image_nids($gid);
      $cache = cache_get('node_gallery:' . $gid . ':image_position');
      $image_position[$gid] = $cache->data;
    }
  }
  return $image_position[$gid][$nid];
}