Project

General

Profile

Actions

Bug #81096

open

Images wrongly cropped in translated pages

Added by Christian Toffolo almost 7 years ago. Updated almost 5 years ago.

Status:
Accepted
Priority:
Must have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Start date:
2017-05-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #80724: Image width="0" and height="0" on translated metadataClosed2017-04-06

Actions
Related to TYPO3 Core - Bug #87162: Width and Height in translated meta data records not updated, when original file is replacedClosed2018-12-14

Actions
Actions #1

Updated by Benni Mack almost 7 years ago

  • Target version changed from 8 LTS to next-patchlevel
Actions #2

Updated by Riccardo De Contardi almost 7 years ago

  • Related to Bug #80724: Image width="0" and height="0" on translated metadata added
Actions #3

Updated by Gianluca Strafella over 6 years ago

Hi,
if it could be useful, this is a dirty work-around to fix the problem on TYPO3 8.7.4 :

$GLOBALS['TCA']['sys_file_metadata']['columns']['width']['l10n_mode'] = 'prefixLangTitle';
$GLOBALS['TCA']['sys_file_metadata']['columns']['width']['config']['type'] = 'user';

$GLOBALS['TCA']['sys_file_metadata']['columns']['height']['l10n_mode'] = 'prefixLangTitle';
$GLOBALS['TCA']['sys_file_metadata']['columns']['height']['config']['type'] = 'user';

based on override of TCA.

Gianluca

Actions #4

Updated by Christian Weiske over 6 years ago

The initial problem is that translated records in sys_file_metadata have a width and height of 0, 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 translated sys_file_metadata record 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 FileMetadataOverlayAspect and reset width and height after calling getRecordOverlay().

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.

Actions #5

Updated by Gerrit Code Review over 6 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/55190

Actions #6

Updated by Gerrit Code Review over 6 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/55190

Actions #7

Updated by Gerrit Code Review over 6 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/55190

Actions #8

Updated by Helmut Hummel over 5 years ago

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)

Actions #9

Updated by Helmut Hummel over 5 years ago

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

Actions #10

Updated by Helmut Hummel over 5 years ago

  • Status changed from Under Review to Accepted
Actions #11

Updated by Helmut Hummel over 5 years ago

  • Related to Bug #87162: Width and Height in translated meta data records not updated, when original file is replaced added
Actions #12

Updated by Benni Mack about 5 years ago

  • Target version changed from next-patchlevel to Candidate for patchlevel
Actions #13

Updated by Torben Hansen almost 5 years ago

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.

Actions

Also available in: Atom PDF