#108598Provide API to create default value for sys_file_reference.crop
Description
Use case
A TYPO3 extension provides an API to create content elements with images.
When an image is imported and a content element created, the image must be connected to the content element via the sys_file_reference table.
To allow proper frontend rendering of the image, the sys_file_reference entry needs a valid value in the crop column – just as if it had been created by hand.
Problem
Manually creating that crop JSON is cumbersome and complex, see https://www.derhansen.de/2021/12/typo3-image-import-crop-variant-string.html
It would be better if TYPO3 would provide a public API method to build that JSON structure.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[FEATURE] Provide API to create default value for sys_file_reference.crop Resolves: #108598 Releases: main
History 1
-
Georg Ringer commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2026-10-18T11:40:38+00:00" > 10/18/26, 11:40 </span>
Thanks for the suggestion.
I’m not sure this is needed. An empty
cropvalue is a valid state:CropVariantCollection::create('')returns an empty collection, and the TCA ofsys_file_reference.crophas no default either. Asys_file_referencewithout crop JSON is rendered in the frontend without any cropping.Could you please describe what exactly does not work when
cropis left empty when importing images and creating thesys_file_referencerecords? Ideally with steps to reproduce (TYPO3 version, how the record is created, expected vs. actual frontend output).If the goal is to pre-fill the crop areas for the crop variants configured in TCA, please mention that explicitly, as that would be a different requirement than “a valid value is needed”. Note that
CropVariantCollection::create($json, $tcaConfig)is already public API.