Project

General

Profile

Actions

Bug #101810

closed

ContentObjectRenderer::getImgResource() ignores cropping settings when passing a FileReference

Added by Kevin Meier about 1 year ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Start date:
2023-08-31
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
Complexity:
no-brainer
Is Regression:
Yes
Sprint Focus:

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.

Actions #1

Updated by Kevin Meier about 1 year ago

  • Target version set to 13.0
Actions #2

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.

Actions #3

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

Actions #4

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

Actions #5

Updated by Friedemann Altrock about 1 year ago

  • Target version changed from 13.0 to Candidate for patchlevel
Actions #6

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

Actions #7

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

Actions #8

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

Actions #9

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

Actions #10

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

Actions #11

Updated by Anonymous about 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #12

Updated by Benni Mack 4 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF