Bug #88024

allowLanguageSynchronization doesn't synchronise cropping from images

Added by Chris Müller 8 months ago. Updated 5 months ago.

Status:
New
Priority:
Must have
Assignee:
-
Category:
Localization
Target version:
-
Start date:
2019-03-27
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I have an image in a TCA and want to reuse this image (and the cropping) in localised records. I configured the field (relevant snippet):

'image' => [
    'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
        'image',
        [
            ...
            'behaviour' => [
                'allowLanguageSynchronization' => true,
            ],
        ]
    ),
]

In backend now I have the possibility to switch between "Custom value"/"Value of default language" in the image field. I created a new record, added an image, cropped it. Now I localised the record, the image with cropping is copied over from the default language.

When I change the cropping of the default language record, the new cropping is not used for the localised record ("Value of default language" is set) in backend preview and frontend output.

When I now change the image in the default language record and apply a cropping, both are set in the localised record.

I encountered the same problem with l10n_mode=exclude: If the cropping is changed later it is not reflected in the localised record.

TYPO3 version 9.5.5

History

#1 Updated by Benni Mack 8 months ago

Hi Chris,

I guess it's not "bubbling down" to all values of the translated record. So you'd need to set this for the fields within sys_file_reference themselves as well. I can't even definitively say that `allowLanguageSynchronization` works with TCA type "imagemanipulation", so this could be an issue as well.

#2 Updated by Chris Müller 8 months ago

First try: I added allowLanguageSynchronization to the crop column in overrideChildTca:

'image' => [
    'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
        'image',
        [
            'overrideChildTca' => [
                'columns' => [
                    'crop' => [
                        'config' => [
                            'behaviour' => [
                                'allowLanguageSynchronization' => true,
                            ],
                        ],
                    ],
                ],
            ],
            'behaviour' => [
                'allowLanguageSynchronization' => true,
            ],
        ],
        $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
    ),
],

When I now open the image tab to see the cropped images I got the exception from the AJAX call:

Call to a member function isCustomState() on null
in /var/www/html/public/typo3/sysext/backend/Classes/Form/FieldWizard/LocalizationStateSelector.php line 96

The problem here is, that

$localizationState = State::fromJSON(
    $this->data['tableName'],
    $this->data['databaseRow'][$l10nStateFieldName] ?? null
);

returns null, because $this->data['databaseRow'][$l10nStateFieldName] is null

So, second try: Add allowLanguageSynchronization directly to sys_file_reference:

'crop' => [
    'exclude' => true,
    'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.crop',
    'config' => [
        'type' => 'imageManipulation',
        'behaviour' => [
            'allowLanguageSynchronization' => true,
        ],
    ]
],

That works, if the cropping is changed in the default language record, the translated record shows also the new cropping.

Are there drawbacks if allowLanguageSynchronization is allowed for all sys_file_reference records? But nevertheless I think, allowLanguageSynchronization should be possible also in overrideChildTca config.

#3 Updated by André Schließer 5 months ago

Thx Chris for your research.

Following your second try by overriding the sys_file_reference TCA with

$GLOBALS['TCA']['sys_file_reference']['columns']['crop']['config']['behaviour']['allowLanguageSynchronization'] = true;

the crop is updated on every change in default lang in those cases:

1. Crop values on images with 'l10n_mode' => 'exclude' are correctly updated
2. Translate able images if "Value of default language"

'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
                'image',
                [
                    'behaviour' => [
                        'allowLanguageSynchronization' => true,
                    ],

If the image is set to "Custom value" the crop is not updated. So it's working fine for me!

Also available in: Atom PDF