Projet

Général

Profil

Révision 4444412d

Ajouté par Julien Enselme il y a environ 10 ans

Update drupal 7.27 -> 7.28

Voir les différences:

drupal7/modules/node/node.api.php
1033 1033
 * This hook is invoked only on the module that defines the node's content type
1034 1034
 * (use hook_node_delete() to respond to all node deletions).
1035 1035
 *
1036
 * This hook is invoked from node_delete_multiple() after the node has been
1037
 * removed from the node table in the database, before hook_node_delete() is
1038
 * invoked, and before field_attach_delete() is called.
1036
 * This hook is invoked from node_delete_multiple() before hook_node_delete()
1037
 * is invoked and before field_attach_delete() is called.
1038
 *
1039
 * Note that when this hook is invoked, the changes have not yet been written
1040
 * to the database, because a database transaction is still in progress. The
1041
 * transaction is not finalized until the delete operation is entirely
1042
 * completed and node_delete_multiple() goes out of scope. You should not rely
1043
 * on data in the database at this time as it is not updated yet. You should
1044
 * also note that any write/update database queries executed from this hook are
1045
 * also not committed immediately. Check node_delete_multiple() and
1046
 * db_transaction() for more info.
1039 1047
 *
1040 1048
 * @param $node
1041 1049
 *   The node that is being deleted.
......
1063 1071
 * @ingroup node_api_hooks
1064 1072
 */
1065 1073
function hook_prepare($node) {
1066
  if ($file = file_check_upload($field_name)) {
1067
    $file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
1068
    if ($file) {
1069
      if (!image_get_info($file->uri)) {
1070
        form_set_error($field_name, t('Uploaded file is not a valid image'));
1071
        return;
1072
      }
1073
    }
1074
    else {
1074
  $file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
1075
  if ($file) {
1076
    if (!image_get_info($file->uri)) {
1077
      form_set_error($field_name, t('Uploaded file is not a valid image'));
1075 1078
      return;
1076 1079
    }
1077
    $node->images['_original'] = $file->uri;
1078
    _image_build_derivatives($node, TRUE);
1079
    $node->new_file = TRUE;
1080 1080
  }
1081
  else {
1082
    return;
1083
  }
1084
  $node->images['_original'] = $file->uri;
1085
  _image_build_derivatives($node, TRUE);
1086
  $node->new_file = TRUE;
1081 1087
}
1082 1088

  
1083 1089
/**

Formats disponibles : Unified diff