Using a fixed aspect ratio, we have some users who upload an image, but because the aspect ratio is fixed (square), the crop looks fine the way it is after the file is uploaded... so they never touch the cropping tool.

As a result, on save, the "changed" variable is not set... so the actually scale and crop never takes place.

I'm not sure the best way to deal with this is... ideally in the javascript once a new image is uploaded... regardless of the cropper being touched, "changed" should be true.

For a quick fix, i changed imagefield_crop_widget.inc, and removed the check for changed crop which is fine for my application...

   # image is never cropped if the cropping tool isn't touched.
    #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']);
    #}

Comments

dayre’s picture

Oops, that actually won't work if you there is no file present (which happens on new uploads):

    # image is never cropped if the cropping tool isn't touched.
    #if ($crop['changed']) {
    if ($file && $file['fid']) {
      // 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']);
    }

I know this won't be suitable for everyone, but it works for me.

Bilmar’s picture

subscribing

balintbrews’s picture

Status: Active » Closed (duplicate)