function hook_prepare

7.x node.api.php hook_prepare($node)
6.x node.php hook_prepare(&$node)

Act on a node object about to be shown on the add/edit form.

This hook is invoked only on the module that defines the node's content type (use hook_node_prepare() to act on all node preparations).

This hook is invoked from node_object_prepare() before the general hook_node_prepare() is invoked.

Parameters

$node: The node that is about to be shown on the add/edit form.

Related topics

6 functions implement hook_prepare()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

book_node_prepare in drupal-7.x/modules/book/book.module
Implements hook_node_prepare().
callback_filter_prepare in drupal-7.x/modules/filter/filter.api.php
Provide prepared text with special characters escaped.
comment_node_prepare in drupal-7.x/modules/comment/comment.module
Implements hook_node_prepare().
menu_node_prepare in drupal-7.x/modules/menu/menu.module
Implements hook_node_prepare().
node_object_prepare in drupal-7.x/modules/node/node.module
Prepares a node object for editing.

... See full list

1 invocation of hook_prepare()
node_object_prepare in drupal-7.x/modules/node/node.module
Prepares a node object for editing.

File

drupal-7.x/modules/node/node.api.php, line 1073
Hooks provided by the Node module.

Code

function hook_prepare($node) {
  if ($file = file_check_upload($field_name)) {
    $file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
    if ($file) {
      if (!image_get_info($file->uri)) {
        form_set_error($field_name, t('Uploaded file is not a valid image'));
        return;
      }
    }
    else {
      return;
    }
    $node->images['_original'] = $file->uri;
    _image_build_derivatives($node, TRUE);
    $node->new_file = TRUE;
  }
}