? .svn ? po/.svn ? tests/.svn ? translations/.svn Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/README.txt,v retrieving revision 1.5 diff -u -p -r1.5 README.txt --- README.txt 16 Mar 2009 23:34:17 -0000 1.5 +++ README.txt 28 Jun 2009 13:31:24 -0000 @@ -18,6 +18,7 @@ ImageField also provides additional feat * Token (Generate dynamic paths when saving images.) * ImageCache (Create thumbnails of images on output.) + * ImageAPI (Rotation of uploaded images.) Install ------- Index: imagefield.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.module,v retrieving revision 1.99 diff -u -p -r1.99 imagefield.module --- imagefield.module 20 Apr 2009 23:57:17 -0000 1.99 +++ imagefield.module 28 Jun 2009 13:31:26 -0000 @@ -6,6 +6,33 @@ * ImageField core hooks and menu callbacks. */ + +/** + * Implementation of hook_nodeapi(). + */ +function imagefield_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { + switch ($op) { + case 'presave': + //Get an array of each imagefield fieldname + $imagefields = array(); + $cck_fields = content_fields(); + foreach($cck_fields as $cck_field) { + if($cck_field['widget']['type']=='imagefield_widget') { + $fieldnames[] = $cck_field['field_name']; + } + } + foreach($fieldnames as $fieldname) { + if ($node->$fieldname) { + foreach($node->$fieldname as $element) { + imagefield_rotate($element); + } + } + } + break; + } +} + + /** * Implementation of hook_init(). * Index: imagefield_file.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield_file.inc,v retrieving revision 1.18 diff -u -p -r1.18 imagefield_file.inc --- imagefield_file.inc 14 Apr 2009 01:28:52 -0000 1.18 +++ imagefield_file.inc 28 Jun 2009 13:31:27 -0000 @@ -94,3 +94,38 @@ function imagefield_create_admin_thumb($ drupal_set_message(t('An image thumbnail was not able to be created.'), 'error'); } } + + +/** + * Process rotation of submitted images + */ +function imagefield_rotate($element) { + if ($element['rotate'] && module_exists('imageapi')) { + //Rotate the saved image + $image = imageapi_image_open($element['filepath']); + imageapi_image_rotate($image, $element['rotate']); + imageapi_image_close($image); + + //Flush admin previews + $files_dir = file_directory_path(); + $replacecount = 1; + $filepath_rel = str_replace($files_dir, '', $element['filepath'], $replacecount); + $admin_preview = $files_dir .'/imagefield_thumbs'. $filepath_rel; + if (file_exists($admin_preview)) { + unlink($admin_preview); + //Generate new admin preview + } + + //Flush imagecache presets + if (function_exists('imagecache_presets')) { + $presets = imagecache_presets(); + foreach($presets as $preset) { + $cachefile = $files_dir .'/imagecache/'. $preset['presetname'] . $filepath_rel; + if (file_exists($cachefile)) { + unlink($cachefile); + } + } + } + + } +} Index: imagefield_widget.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield_widget.inc,v retrieving revision 1.37 diff -u -p -r1.37 imagefield_widget.inc --- imagefield_widget.inc 20 Apr 2009 23:51:35 -0000 1.37 +++ imagefield_widget.inc 28 Jun 2009 13:31:27 -0000 @@ -261,6 +261,22 @@ function imagefield_widget_process($elem if ($default_title) { $element['data']['title']['#value'] = $field['widget']['title']; } + + // Add rotation widget + if (module_exists('imageapi')) { + $element['rotate'] = array( + '#type' => 'select', + '#title' => t('Rotate'), + '#options' => array( + 0 => t('None'), + 90 => t('90 degrees clockwise'), + 180 => t('180 degrees'), + 270 => t('90 degrees anti-clockwise'), + ), + '#default_value' => 0, + ); + } + return $element; }