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.
Updated by Friedemann Altrock about 1 year ago
I think a better solution would be to set $fileReference
in the branch elseif ($file instanceof FileReference)
at https://github.com/TYPO3-CMS/frontend/blob/b2f4583df4ded65078d791419141f5b872580c18/Classes/ContentObject/ContentObjectRenderer.php#L3744C15-L3744C54 .
I'll try to reproduce this and make a patch.
Updated by Gerrit Code Review about 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80812
Updated by Gerrit Code Review about 1 year ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80812
Updated by Friedemann Altrock about 1 year ago
- Target version changed from 13.0 to Candidate for patchlevel
Confirmed the bug with 12.4.5 and 11.5.30.
Reproduction: https://github.com/fwg/typo3-bugs/tree/forge/101810
Fixed: https://github.com/fwg/typo3-bugs/tree/forge/101810-fix
Patch can be applied with cweagans/composer-patches:^1.7 like this: https://github.com/fwg/typo3-bugs/blob/a97611fe8d2d143ad940aaa42c56c220b32f65cf/composer.json#L62-L66
Updated by Gerrit Code Review about 1 year ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80812
Updated by Gerrit Code Review about 1 year ago
Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80812
Updated by Gerrit Code Review about 1 year ago
Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80812
Updated by Gerrit Code Review about 1 year ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80906
Updated by Gerrit Code Review about 1 year ago
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80928
Updated by Anonymous about 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 1ef77286e7bac52b5137cef50fa52459c862b481.