You are here

function imagefield_crop_widget_value in Imagefield Crop 6

Same name and namespace in other branches
  1. 7 imagefield_crop.module \imagefield_crop_widget_value()
1 string reference to 'imagefield_crop_widget_value'
imagefield_crop_elements in ./imagefield_crop.module
Implementation of hook_elements().

File

./imagefield_crop_widget.inc, line 247

Code

function imagefield_crop_widget_value($element, $edit = FALSE) {
  if ($edit && isset($edit['data'])) {
    $file = field_file_load($edit['fid']);
    $field = content_fields($element['#field_name'], $element['#type_name']);
    $crop = $edit['data']['crop'];
    if ($field['widget']['resolution']) {
      list($scale['width'], $scale['height']) = explode('x', $field['widget']['resolution']);
    }
    if ($crop['changed']) {

      // save crop time, for preview
      variable_set('imagefield_crop_query_string', REQUEST_TIME);
      _imagefield_crop_resize(imagefield_crop_file_admin_original_path($file), $crop, $scale, $file['filepath']);
    }
  }
  return module_invoke('filefield', 'widget_value', $element, $edit);
}