diff --git a/imagefield_crop.module b/imagefield_crop.module index c40dba3..4a73601 100644 --- a/imagefield_crop.module +++ b/imagefield_crop.module @@ -129,13 +129,14 @@ function _imagefield_crop_widget_resolution_validate($element, &$form_state) { function _imagefield_crop_widget_enforce_ratio_validate($element, &$form_state) { $settings = $form_state['values']['instance']['widget']['settings']; - if ($settings['resolution'] && !$element['#value']) { + if (!empty($settings['resolution']) && (!$element['#value'])) { drupal_set_message(t('Output resolution is defined, but not enforced. Final images might be distroted')); } } function _imagefield_crop_widget_enforce_minimum_validate($element, &$form_state) { $settings = $form_state['values']['instance']['widget']['settings']; + $rw = $rh = 0; list($rw, $rh) = !empty($settings['resolution']) ? explode('x', $settings['resolution']): array(0, 0); if ($settings['enforce_minimum'] && @@ -225,8 +226,13 @@ function imagefield_crop_widget_process($element, &$form_state, $form) { $file_to_crop = _imagefield_crop_file_to_crop($element['#file']->fid); $element['cropinfo'] = _imagefield_add_cropinfo_fields($element['#file']->fid); - list($res_w, $res_h) = explode('x', $widget_settings['resolution']); - list($crop_w, $crop_h) = explode('x', $widget_settings['croparea']); + $res_w = $res_h = 0; + $crop_w = $crop_h = 0; + + if (!empty($widget_settings['resolution']) && (!empty($widget_settings['croparea']))) { + list($res_w, $res_h) = explode('x', $widget_settings['resolution']); + list($crop_w, $crop_h) = explode('x', $widget_settings['croparea']); + } $element['preview'] = array( '#type' => 'markup', @@ -312,6 +318,7 @@ function imagefield_crop_widget_preview_process($element, &$form_state, $form) { $parents = array_slice($element['#array_parents'], 0, -1); $parent = drupal_array_get_nested_value($form, $parents); $instance = field_widget_instance($parent, $form_state); + $width = $height = 0; if ($instance['widget']['settings']['resolution']) { list($width, $height) = explode('x', $instance['widget']['settings']['resolution']); } @@ -353,6 +360,7 @@ function imagefield_crop_widget_value(&$element, &$input, $form_state) { // get crop and scale info $crop = $input['cropinfo']; + $scale = NULL; $instance = field_widget_instance($element, $form_state); $scale = NULL; if ($instance['widget']['settings']['resolution']) {