#81096Images wrongly cropped in translated pages
Description
sys_file_metadata stores width/height of an image in the record with sys_language_uid=0 while in the translated records with sys_language_uid!=0 width/height are 0.
Then \TYPO3\CMS\Frontend\Page\PageRepository::getRecordOverlay() overlays the right dimensions in the $row with the 0 from $olrow even if TCA of sys_file_metadata has ‘l10n_mode’ => ‘exclude’ for the fields ‘width’ and ‘height’.
The image then is often wrongly cropped in the translated pages.
Reviews 1
Related issues 2
History 1114
-
Benni Mack changed target version <span data-processor="relativetime" data-value="2017-05-04T17:47:38+00:00" > 05/04/17, 17:47 </span>
-
Riccardo De Contardi changed Related to #80724 <span data-processor="relativetime" data-value="2017-05-04T21:21:47+00:00" > 05/04/17, 21:21 </span>
-
Gianluca Strafella commented <span data-processor="relativetime" data-value="2017-12-05T11:30:43+00:00" > 12/05/17, 11:30 </span>
-
Christian Weiske commented <span data-processor="relativetime" data-value="2017-12-21T15:49:48+00:00" > 12/21/17, 15:49 </span>
The initial problem is that translated records in
sys_file_metadatahave awidthandheightof0, unlike their untranslated counterparts that have those properties filled correctly.Coarse call stack:
- MetaDataRepository->findByFile() - MetaDataRepository->emitRecordPostRetrievalSignal() - FileMetadataOverlayAspect->languageAndWorkspaceOverlay() - TYPO3\CMS\Frontend\Page\PageRepository->getRecordOverlay()PageRepository.php::getRecordOverlay()fetches the translatedsys_file_metadatarecord and overlays all properties of the original row without caring if they should be overlaid at all:// Merge record content by traversing all fields
——
A solution is to adjust
FileMetadataOverlayAspectand resetwidthandheightafter callinggetRecordOverlay().Another solution would be to copy width and height of the original metadata record to the translated ones – but this might cause issue when updating/replacing the file, since the size data would need to be re-propagated then.
-
Gerrit Code Review pushed patch set 1 for master to change 55190 status
NewUnder Review <span data-processor="relativetime" data-value="2017-12-21T15:54:34+00:00" > 12/21/17, 15:54 </span> -
Gerrit Code Review pushed patch set 2 for master to change 55190 <span data-processor="relativetime" data-value="2017-12-30T12:13:57+00:00" > 12/30/17, 12:13 </span>
-
Gerrit Code Review pushed patch set 3 for master to change 55190 <span data-processor="relativetime" data-value="2017-12-30T12:14:28+00:00" > 12/30/17, 12:14 </span>
-
Helmut Hummel commented <span data-processor="relativetime" data-value="2018-11-13T18:16:32+00:00" > 11/13/18, 18:16 </span>
The reason for that is the following. Despite width and height being configured to be synced for translations (l10_mode = exclude), DataHandler does NOT sync these fields, if editors do not have permissions to edit/change them.
This DataHandler behaviour is unfortunate, because these fields are read only anyway.We fixed this in our project by simply setting the tca value of ‘exclude’ to ‘false’. This makes the readonly fields appear in the default language, but also syncs the width and height properly, when saving any meta data record (translation or default language does not matter)
-
Helmut Hummel commented <span data-processor="relativetime" data-value="2018-11-13T18:20:51+00:00" > 11/13/18, 18:20 </span>
TSCONFIG:
TCEFORM.sys_file_metadata.height.disabled = 1 TCEFORM.sys_file_metadata.width.disabled = 1
TCA:
$GLOBALS['TCA'][$table]['columns']['width']['exclude'] = false; $GLOBALS['TCA'][$table]['columns']['height']['exclude'] = false;
Setting both works as expected. Fields are not show, but DataHandler sync works
-
Helmut Hummel changed status
Under ReviewAccepted <span data-processor="relativetime" data-value="2018-11-13T18:22:54+00:00" > 11/13/18, 18:22 </span> -
Helmut Hummel changed Related to #87162 <span data-processor="relativetime" data-value="2018-12-14T12:32:32+00:00" > 12/14/18, 12:32 </span>
-
Benni Mack changed target version <span data-processor="relativetime" data-value="2019-04-17T23:41:05+00:00" > 04/17/19, 23:41 </span>
-
Torben Hansen commented <span data-processor="relativetime" data-value="2019-06-26T08:50:23+00:00" > 06/26/19, 08:50 </span>
Same problem here. Images with the wrong size (0 width/height) are not visible in frontend output of translated pages. Pretty hard to understand for editors what is going wrong, since the image is shown in backend but not in frontend context.
Thanks Helmut for pointing out a solution.
-
Georg Ringer commented and changed status
AcceptedClosed <span data-processor="relativetime" data-value="2026-10-06T20:56:54+00:00" > 10/06/26, 20:56 </span>this has been fixed, e.g. with #81964.
Hi,
if it could be useful, this is a dirty work-around to fix the problem on TYPO3 8.7.4 :
based on override of TCA.
Gianluca