Project

General

Profile

Actions

Bug #106554

closed

Localized images (media files) of sys_file_reference is not translated in frontend

Added by Dmytro Doronenko 17 days ago. Updated 10 days ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
Content Rendering
Target version:
Start date:
2025-04-11
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
13
PHP Version:
8.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Prerequisites

I have setup a clean environment to reproduce the issue.

PHP 8.3 / 8.4

TYPO3 13.4.9 (composer based)

Setup at least 2 languages with strict fallback (0 = EN, 1 = DE).

Content rendering done with PAGEVIEW cObject + ContentBlocks

A partial solution was done in https://forge.typo3.org/issues/106303

Steps to reproduce:

1. Create Text & Media with image_1 (sys_file_reference) attached on default language [EN]
2. Translate Text & Media to DE language and change image_1 to image_2 (diffrent image). New sys_file_reference does not have l10_parent value.
3. On the frontend of DE language: the image is missing as localized image_2 was not found.

Expected result

Have the possibility to set different images(media) for translated content and keep Strict fallback mode for DE lang.
Basic user case: image with the EN text and for translated DE page it should be image with DE text

Rendering with CONTENT cObject still works properly

In case Content cObject is used to render elements by colPos -> the DE Text & Media is rendered properly with localized image_2 ( file reference l10_parent = 0)

While the records fething the tt_content records is overlayed and _LOCALIZED_UID property is attached to record data array. See:

\TYPO3\CMS\Frontend\ContentObject\ContentContentObject::render
\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getRecords
\TYPO3\CMS\Core\Domain\Repository\PageRepository::getLanguageOverlay

Issue / Problem

According to PAGEVIEW content rendering is done via "page-content" data processor

While debugging "page-content" data processor: the result (RawRecord) is correct. The correct localized sys_file_reference is properly found (image_2)

Then, according to docs: Resources/PageView/Default/Default.html

 <f:for each="{content.main.records}" as="record">
     <f:cObject typoscriptObjectPath="{record.mainType}" table="{record.mainType}" data="{record}"/>
 </f:for>
Next \TYPO3\CMS\Fluid\ViewHelpers\CObjectViewHelper::render handles content elements rendering, and that's why the issue appears
 vendor/typo3/cms-fluid/Classes/ViewHelpers/CObjectViewHelper.php:86
 $data = $data instanceof RecordInterface ? ($data->getRawRecord()?->toArray() ?? $data->toArray()) : ObjectAccess::getGettableProperties($data);

$data->getRawRecord()?->toArray() return record array with "_computed" property where "localizedUid" is stored but NOT "_LOCALIZED_UID" property in the record data array. ..... some processing and it gets to "files" data processor

\TYPO3\CMS\Frontend\Resource\FileCollector::addFilesFromRelation
\TYPO3\CMS\Frontend\Resource\FileCollector::getFileReferences

as "_LOCALIZED_UID" is not presented the localized fileReference not found

$localizedId = $element['_LOCALIZED_UID'] ?? null;

$isTableLocalizable = (
   !empty($GLOBALS['TCA'][$tableName]['ctrl']['languageField'])
   && !empty($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'])
);
if ($isTableLocalizable && $localizedId !== null) {
....

As a result on frontend: image_2 (sys_file_reference) is not found and missing.

1st Solution

Add _LOCALIZED_UID value in RawRecord model for further proper usage in \TYPO3\CMS\Frontend\Resource\FileCollector::getFileReferences

vendor/typo3/cms-core/Classes/Domain/RawRecord.php:73
$properties += ['uid' => $this->uid, 'pid' => $this->pid, '_LOCALIZED_UID' => $this->getComputedProperties()->getLocalizedUid()];

2nd Solution

Respect/use new "record -> _computed -> localizedUid" value in \TYPO3\CMS\Frontend\Resource\FileCollector::getFileReferences for the proper localized file reference(s) fetching.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #106303: Image description of sys_file_reference is not translated in frontendResolved2025-03-04

Actions
Actions #1

Updated by Dmytro Doronenko 17 days ago

  • Description updated (diff)
Actions #2

Updated by Dmytro Doronenko 17 days ago

  • Related to Bug #106303: Image description of sys_file_reference is not translated in frontend added
Actions #3

Updated by Dmytro Doronenko 17 days ago

  • Description updated (diff)
Actions #4

Updated by Gerrit Code Review 11 days 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/+/89157

Actions #5

Updated by Gerrit Code Review 10 days 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/+/89157

Actions #6

Updated by Gerrit Code Review 10 days 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/+/89157

Actions #7

Updated by Gerrit Code Review 10 days ago

Patch set 1 for branch 13.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/+/89168

Actions #8

Updated by Oliver Bartsch 10 days ago

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

Also available in: Atom PDF