views:

49

answers:

1

Can I initialize the cropping area (In order to suggest a default one), with the Imagecrop module ?

I want my users to crop images in the same way...

thanks

Update: code lines in imagefield_crom.js

setSelect: [
          parseInt($(".edit-image-crop-x", widget).val()),
          parseInt($(".edit-image-crop-y", widget).val()),
          parseInt($(".edit-image-crop-width", widget).val()) + parseInt($(".edit-image-crop-x", widget).val()),
          300 + parseInt($(".edit-image-crop-y", widget).val())
        ]
+2  A: 

Imagefield Crop uses the following jQuery plugin http://deepliquid.com/content/Jcrop_Manual.html

The function that you should be interested in is setSelect which sets the initial cropping area.

You can have a look in the file imagefield_crop.js (in the imagefield_crop module folder) where the function setSelect is being called. The default there is to set the selection area to the whole image -- you might want to recommend some other size and starting coordinates.

Alternative Answer Check out http://drupal.org/project/imagecrop

Sid NoParrots
do you mean the lines I've added to the question ? I've changed one of them (hardcoded 300) but it didn't work
Patrick
Sorry I didn't try it myself though I really think that this is the place where the magic happens. Did you get an opportunity to go through this in firebug javascript debugger? Did you check out imagecrop? I haven't deeply explored that but it could be what you want.
Sid NoParrots
In answer to your question, the lines you have posted seem to the correct ones that will control the initial select area, I believe. BTW http://drupal.org/project/imagecrop is a different from imagefield_crop
Sid NoParrots
yeah it works. The only thing is that I need to move or resize the dragged area to save the changes. In other words, the preview is not considered for the real cropping. Do you know how can I crop using the default cropping without having to drag the area at all ?
Patrick
What works imagecrop or fiddling with `setSelect` ? -- not clear from your comment.
Sid NoParrots
The initial cropping changes, and I can set it as I want. However it is not cropping the image. In other words, I have to make a change to the cropping area with the mouse (dragging or resizing) in order to make it crop the image.
Patrick
You should explore issuing the `onSelect` event. This event is fired when the selection ends. See the Jcrop manual. Another scenario is to not change `imagfield_crop.js` but explicitly issue a `setSelect` command later on in some js included from a custom module. You'll have to do some jQuery hacking basically :-)
Sid NoParrots
uhm.. yeah.. the point is that I don't want to change the cropping area when an old node is edited.. you know what I mean, I want to preserve the cropping area. I only want to change it if it is a new image.
Patrick
Yes, I understand. This requires some thought. I'll play around with it if I get some time.
Sid NoParrots

related questions