You are here

function img_assist_nodeapi in Image Assist 5

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

Implementation of hook_nodeapi().

  • Clear input filter cache.
  • Keep track of where images are used.
  • Catch nids of recently uploaded images.

@todo Remove usage of global variable.

File

./img_assist.module, line 419
Image Assist module

Code

function img_assist_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'update':
      if ($node->type == 'image') {

        // Clear the input filter cache to force all node content to be rebuilt.
        // This is to make sure all image paths are up to date.
        cache_clear_all(NULL, 'cache_filter');
      }

    // break is intentionally left out.
    case 'insert':

      // Update the image map.
      img_assist_map_save($node);

      // Store nid globally if this node is an image uploaded with img_assist.
      if ($node->type == 'image' && arg(0) == 'img_assist') {
        global $_img_assist_saved_image;
        $_img_assist_saved_image = $node->nid;
      }
      break;
    case 'delete':
      img_assist_map_delete($node);
      break;
  }
}