I agree that this module is a great method for managing photos for nodes. Thanks for the project.

Currently (at least on our website) the crop area defaults to the minimum width and minimum height for the cropped image (if there is no minimum in the admin settings page, then the crop area defaults to 0x0!).

I am using the 1.x version. It should include a setting for the default crop size. Ideally, the width or height of the image (maintaining ratio if also set in the admin screen) is read in and then the crop area that appears over the image is set to the maximum size for the original image. The website visitor may then reduce the size of the crop area.

Patch to follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jjchinquist’s picture

Just need a little help to determine the different values for Jcrop defined in imagefield_crop.js:
boxWidth: is this the width of the preview image on top of which the crop selector is placed, or is this the actual crop selector width?
boxHeight: same question as above.

Is there a javascript event that is fired when the image is loaded?
What event can I trigger that would cause the crop selector to resize when the preview image is loaded?

Thanks.

jjchinquist’s picture

Ok - event trigger answer is the following:
http://deepliquid.com/content/Jcrop_Manual.html#Setting_Options
setSelect array [ x, y, x2, y2 ] Set an initial selection area n/a

boxWidth/boxHeight seems to be the cropping area (the image preview that the crop selector is placed on top of), not the cropping selector itself.

jjchinquist’s picture

Status: Active » Needs review
FileSize
2.48 KB

Patch attached - please test/commit. Checked on 1 production website.

joetsuihk’s picture

@jjchinquist thank you for the patch and sorry for this late reply, but can you explain "50" in

parseInt($(widget).siblings(".edit-image-crop-width").val()) == 50

why is it 50?

jjchinquist’s picture

As far as I know, the 50 px was a default "if nothing else applies". Please let me know if I should change this and I can.

mavimo’s picture

Changing approach, patch to set default cropping size to minimum value between width and height of image size as cropping area.

mavimo’s picture

Fixed error on variable renaming.

valthebald’s picture

Status: Needs review » Reviewed & tested by the community

This saved my day! Cleanly applies to the latest release. Can we get this in, please?

ram4nd’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
ram4nd’s picture

Status: Patch (to be ported) » Needs work

Re-roll against latest state.

bluetegu’s picture

I re-rolled mavimo's solution against latest 1.x dev, and centred the preview

tkuldeep17’s picture

I am not able to apply patch jcrop-default-crop-settings-1506460-7.patch. It is failing. so creating new one.

tkuldeep17’s picture

Status: Needs work » Needs review
tkuldeep17’s picture

Added setting for crop area ratio and position.

tkuldeep17’s picture

FileSize
3.64 KB

Sorry uploading path again. Fixing some errors.

prat’s picture

Submitting patch agains 1.x dev, using @bluetegu patch, just changed the paths that were unnecessary included and thus causes issues on automated builds.

jenlampton’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch @prat, still works for me!