You are here

function img_assist_block in Image Assist 6

Same name and namespace in other branches
  1. 5.3 img_assist.module \img_assist_block()
  2. 5 img_assist.module \img_assist_block()
  3. 5.2 img_assist.module \img_assist_block()
  4. 6.2 img_assist.module \img_assist_block()

Implementation of hook_block().

Generates a block that references the other places the current image is used. The block is only visible when looking at the full view of an image.

File

./img_assist.module, line 169
Image Assist module

Code

function img_assist_block($op = 'list', $delta = 0) {
  if ($op == 'list') {
    $blocks[0]['info'] = t('Image reference');
    return $blocks;
  }
  else {
    if ($op == 'view') {
      switch ($delta) {
        case 0:

          // Since blocks aren't passed node objects (which makes sense) we need
          // to determine if we are viewing a node and grab its nid.
          if (arg(0) == 'node' && is_numeric(arg(1))) {
            $block['subject'] = t('This image appears in...');
            $block['content'] = img_assist_get_references(arg(1));
            return $block;
          }
          break;
      }
    }
  }
}