Add custom ratios to the Image Upload add-on
The Image Upload addon allows you to configure ratios for uploaded images. This allows customers to crop their images directly in the browser to the ratio you require and it ensures you receive the image in the correct proportions every time.
The plugin comes with some popular aspect ratios to select from, but you may need more. You can freely add your own ratios by adding the following code snippet to your theme (read here how):
Supply your license key to unlock the code
Since this is a custom-coded snippet, please enter your license key so we can verify your purchase.
In the above code snippet, we add 2 extra ratios: 2:3
and 3:4
. You can add as many as you like.
Let’s take a look at how to build the code. For each ratio you need, you add a line similar to:
$ratios['0.66666'] = '2:3';
Where 0.66666
is simply the calculation of 2/3 and 2:3
is the display label.
Once you’ve saved the code snippet, you will be able to select your custom ratios in the field settings.