How to center jQuery JCrop in the center of the image

I want to start selecting JCrop in the center of the image. Is there any way to do this?

Is there an option or something else? This is not indicated in the manual.

Does it need to be calculated manually?

+7
source share
1 answer

If you cannot determine how to set the selection in the center:

Check your settings http://deepliquid.com/content/Jcrop_Manual.html#Setting_Options

Something like this (taken from API ref):

<script language="Javascript"> jQuery(function($) { $('#target').Jcrop({ onSelect: showCoords, bgColor: 'black', bgOpacity: .4, setSelect: [ x, y, x1, y1 ], aspectRatio: 16 / 9 }); }); </script> 

If w is the width and h is the height desired selection and W is the width of the image , H is the height of the image , the coordinates will be

 x = W/2 - w/2 y = H/2 - h/2 x1 = x + w y1 = y + h 

(I hope my math is correct :)

+15
source

All Articles