You are here

function image_view in Image 5

Same name and namespace in other branches
  1. 5.2 image.module \image_view()
  2. 6 image.module \image_view()

Implementation of hook_view

File

./image.module, line 565

Code

function image_view($node, $teaser = 0, $page = 0) {
  $sizes = image_get_sizes();
  $size = IMAGE_PREVIEW;
  if (isset($_GET['size'])) {

    // Invalid size specified.
    if (!isset($sizes[$_GET['size']])) {
      drupal_goto("node/{$node->nid}");
    }
    $size = $_GET['size'];

    // Not allowed to view the original.
    if ($size == IMAGE_ORIGINAL && !user_access('view original images')) {
      drupal_goto("node/{$node->nid}");
    }
  }
  $node = node_prepare($node, $teaser);
  $node->content['image'] = array(
    '#value' => theme($teaser ? 'image_teaser' : 'image_body', $node, $size),
    '#weight' => 0,
  );
  return $node;
}