Configure defaults: aspect ratios
You can control what crop rectangle aspect ratios are available to your users.
By default CROPRO is initialized with a set of most common aspect ratios and defaults to a "free" ratio.
Setting available ratios
To set what ratios are available in the aspect ratio dropdown you set the CropArea.aspectRatios
array to a list of available ratios.
Here's an example:
cropArea.aspectRatios = [
{ horizontal: 1, vertical: 1 },
{ horizontal: 3, vertical: 2 },
{ horizontal: 2, vertical: 3 }
];
Here we set that users can choose between square (1:1), 3:2, and 2:3 ratios.
CROPRO defaults to the first ratio in the array on launch but you can change this by setting CropArea.aspectRatio
property to something else:
// default to the third element in the array
cropArea.aspectRatio = cropArea.aspectRatios[2];
While not a strict requirement, it's always a good idea to set aspectRatio
to a value from the aspectRatios
array so users have a way to return to the default ratio after changing it.
See also
- Aspect ratios demo
- Reference:
CropArea.aspectRatios
- Reference:
CropArea.aspectRatio
- Reference:
IAspectRatio