Hi Daniele,
Bricksforge version: 4.0.2
Bricks version: 2.4
IMO, this is a bug:
Description:
When “Activate Image Editor” is enabled on a Pro Forms File field and “Allow Crop” is disabled,
every uploaded image is still cropped to a 16:9 aspect ratio before upload. The user has no
crop tool and no way to choose the visible area, so wider or taller images are silently cut off.
Cause (includes/elements/pro-forms/elements/File.php):
- Line 1488: if no “data-crop-aspect-ratio” attribute is present, the script falls back to ‘16/9’:
let cropAspectRatio = element.getAttribute(‘data-crop-aspect-ratio’) ? … : ‘16/9’; - Line 1654: this value is always passed to the editor as imageCropAspectRatio, regardless of
whether “Allow Crop” is enabled. - Line 397: the “Crop Aspect Ratio” control has ‘required’ => [‘allowCrop’, ‘=’, true], so it is
hidden in the builder as soon as “Allow Crop” is disabled. The 16:9 default is therefore
applied by a setting the user can neither see nor change.
The description of “Allow Crop” (“If checked, the crop tool will be available”) suggests that
disabling it only removes the tool, not that a fixed crop is enforced.
Steps to reproduce:
- Add a File field to a Pro Forms form.
- Enable “Activate Image Editor”, disable “Allow Crop”, leave everything else at default.
- Upload a logo that is much wider than 16:9 (e.g. 600 x 150 px).
- Inspect the file that arrives on the server / in the media library.
Expected:
The image is uploaded with its original aspect ratio (only resized/compressed according to
the Image Quality and Target Size settings).
Actual:
The image is cropped to 16:9 around its center. In our case a wide logo lost its left and
right parts. The result is a silent loss of image content.
Suggested fix:
Only pass imageCropAspectRatio to the editor when “Allow Crop” is enabled and a ratio is set;
otherwise leave it undefined so the original aspect ratio is kept.
Workaround:
Disable “Activate Image Editor” on fields where cropping is not wanted.
Cheers
Marco