Issue Feature Needs Feedback Quiet

#108598Provide API to create default value for sys_file_reference.crop

Christian Weiske 01/06/26, 13:20 updated 10/18/26, 11:40

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

  1. Georg Ringer commented and changed status New Needs 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 crop value is a valid state: CropVariantCollection::create('') returns an empty collection, and the TCA of sys_file_reference.crop has no default either. A sys_file_reference without crop JSON is rendered in the frontend without any cropping.

    Could you please describe what exactly does not work when crop is left empty when importing images and creating the sys_file_reference records? 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.