Bug #101810
closedContentObjectRenderer::getImgResource() ignores cropping settings when passing a FileReference
100%
Description
When passing a FileReference object to the ContentObjectRenderer::getImgResource() function, the check for the FileReference fails when adding the cropping settings. From what I saw in the code, this should happen in TYPO3 11 and TYPO3 12 (tested in TYPO3 12) as well as the main branch. The failing check for TYPO3 12.4 can be found under https://github.com/TYPO3-CMS/frontend/blob/12.4/Classes/ContentObject/ContentObjectRenderer.php#L3791
This happens because $fileReference doesn't get set in the case of the first function parameter being a FileReference object. For a fix, instead of
if (isset($fileReference)) {
$processingConfiguration['crop'] = $this->getCropAreaFromFileReference($fileReference, $fileArray);
}
You could do
if (isset($fileReference) || $file instanceof FileReference) {
$processingConfiguration['crop'] = $this->getCropAreaFromFileReference($fileReference ?? $file, $fileArray);
}
I don't know if that's clean code, just a basic idea. Also I don't know how to create patches but feel free to do so.