Issue is:
(summarised from http://drupal.org/node/212576)
After you crop an existing image, the image you see in your browser is a cached version of the image. You need to press 'Refresh' on your browser to refresh to the cropped image.

It *would* be the cleanest solution to rename the file if this was an independent module. However, this is just a widget on top of imagecache field, and as far as imagefield is concerned, this is the same file, so no necessary updates are not being made on the node.

Comments

bones’s picture

My solution, although it may not be 'correct' is to change the filename and update the files data base table changing line 179 onwards to:

    case 'submit':
      /*
       ** move cropped file into the file's place
       */
      foreach ($node_field as $delta => $file) {
        $cropped = $file['crop']['filepath'];
        if (is_file($cropped)) {
          if (!file_copy($cropped, $file['filepath'], FILE_EXISTS_RENAME)) {
            form_set_error(NULL, 'Could not copy cropped file');
          }
          //delete temp file
          file_delete($file['crop']['filepath']);
          //delete old file (if there is one)
          if($cropped != $file['filepath']) {
          	file_delete($file['filepath']);
          }
          //update the node_field object (not sure if necessary)
          $node_field[$delta]['filepath'] = $cropped;
          //update the files table with new path
          db_query('UPDATE {files} SET filepath = "%s" WHERE fid = %d',$cropped,$file['fid']);
        }
        file_delete($file['filepath'] .'.unscaled');
   			//flush the imagecache presets
 				if(module_exists('imagecache')){
 					imagecache_image_flush($file['filepath']);
 				}
      }
      break;
yhager’s picture

Status: Active » Needs work

Does this work for you? I am a bit reluctant with changing the DB directly under the legs of other modules. It might also break with other aspects of the file management (like deleting the old file) should be handled by this module, or if the file handling code of imagefield might change. IMHO, this is the job of other modules.

Let's leave this as a patch here for the moment for whoever wants this functionality, until I gather the right way to implement this. Can you post this in a patch format against the CVS code (http://drupal.org/patch/create)

yhager’s picture

Status: Needs work » Postponed
sime’s picture

Just create a timestamp and add it to the end of the image url eg:

http://example.com/path/to/image/myimage.justcropped.jpg?nocache=21273879432

This will be seen by the browser as a unique file.

Arguably you don't want to do this on the public image, and you don't need to most of the time since all the editing is done when the file is created.

yhager’s picture

Assigned: Unassigned » yhager
Status: Postponed » Active

@sime: thanks for the idea. I'll try that and post here the results.

yhager’s picture

The problem with the suggestion from #4 above is that the imagefield_crop is not consulted upon node_view, so we have no control over what is being displayed..

queenielow’s picture

Thanks for the solution..
I works fine for me..

Thanks alot Bones!

yhager’s picture

Version: 5.x-1.x-dev » 6.x-1.0-beta1
Status: Active » Fixed

This is fixed in the 6.x version, if imagefield is patched with http://drupal.org/node/353405#comment-1224788

yhager’s picture

Version: 6.x-1.0-beta1 » 5.x-1.x-dev
Status: Fixed » Closed (won't fix)

The fix cannot be ported to 5.x, so this is actually a wontfix for 5.x.

johnpitcairn’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

I'm having trouble with this, as per #17 in http://drupal.org/node/353405#comment-1224788, using ImageCache for all non-editing image display:

Imagefield 6.x-3.3
Imagecache 6.x-2.0-beta10
Imagefield Crop 6.x-1.0-rc1

I'm using an "Image" content type, which when viewed as a node just displays the image via an Imagecache preset. Other nodes may nodereference this Image node - these grab the filepath from the nodereference, and display that via an ImageCache theme call (different Imagecache preset).

I'm seeing the timestamp for the image displayed by the widget update on the Image node *edit* page, and the imagefield timestamp in the node is updated, so it appears that's working correctly.

But I'm not seeing any timestamp reflected in the Imagecache filename output on Image node view. So the browser doesn't think the file has changed. Should the Imagecache filename output include the timestamp?

And does/should Imagefield Crop conditionally flush the Imagecache filepath, as per #1?

(I'm also expecting further trouble when I re-enable the Revisioning module, as that will create an unpublished revision and the re-crop should not be public until the revision is published. But that's a separate issue.)

johnpitcairn’s picture