Project

General

Profile

Actions

Bug #85309

closed

Image Manipulation: allowedAspectRatios title must be prefixed with LLL

Added by Benni Mack over 6 years ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Localization
Target version:
-
Start date:
2018-06-19
Due date:
% Done:

0%

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

Description

The following TCA configuration is not possible:

$GLOBALS['TCA']['tt_content']['types']['my_ce']['columnsOverrides']['assets']['config']['overrideChildTca']['columns']['crop']['config'] = [
    'cropVariants' => [
        'default' => [
            'title' => 'LLL:EXT:mysite/Resources/Private/Language/locallang_db.xlf:sys_file_reference.title.default',
            'selectedRatio' => '16:9',
            'cropArea' => [
                'height' => 1.0,'width' => 1.0,'x' => 0.0,'y' => 0.0
            ],
            'allowedAspectRatios' => [
                '16:9' => ['title' => 'LLL:EXT:mysite/Resources/Private/Language/locallang_db.xlf:sys_file_reference.ratio.16-9', 'value' => 16/9],
                '4:3' => ['title' => '4/3', 'value' => 4/3],
            ],
            'focusArea' => [
                'x' => 1 / 3,
                'y' => 1 / 3,
                'width' => 1 / 3,
                'height' => 1 / 3,
            ]
        ],
    ],
];

This is mainly due to the 4:3 aspect reatio, where thte title is "4/3" and then opening up an existing image in side the Image Manipulation Wizard throws an exception, because the Fluid template (within "ImageManipulationWizard.html" has this line of code

 {cropVariant.title -> f:translate(id: cropVariant.title)}

which in turn calls Extbase`s Translate Utility, which needs either a string prefixed with LLL or an extension name given.

Question is: What should we fix?

Actions #1

Updated by Stefan Froemken about 6 years ago

Hello Benni,

in Core we have currently following line in ImageManipulationElement.html:

<f:translate id="{cropVariant.title}" default="{cropVariant.title}" />

And yes, this line sometimes throws an Exception. I'm currently not really know why. Here is an idea:

If f:translate was called the first time it will generate hundreds of compile rows in Cache FluidTemplates:

        return sprintf(
            '\\%1$s::translate(%2$s[\'key\'] ?? %2$s[\'id\'], %2$s[\'extensionName\'] ?? $renderingContext->getControllerContext()->getRequest()->getControllerExtensionName(), %2$s[\'arguments\'], %2$s[\'languageKey\'], %2$s[\'alternativeLanguageKeys\']) ?? %2$s[\'default\'] ?? %3$s()',
            LocalizationUtility::class,
            $argumentsName,
            $closureName
        );

and after that, the render() method will be called. There you will find a try-section which will catch the \InvalidArgumentException, if $extensionName was not given and default $value will be set to {cropVariant.title}.

With next request the compiled FluidTemplate will be called, which you (Core) have drastically changed with the last commits. This compiled FluidTemplate will only call LocalizationUtility::translate(). There is no catch against \InvalidArgumentException anymore. So maybe method compile should create a better compile Template or we can return back to renderStatic as in previous versions.

Nice greetings

Stefan

Actions #2

Updated by Stefan Froemken about 6 years ago

Ok...confirmed. On first request render() will be called which catches the Exceptions and at second request the compiled version will be called, which does not catch the Exception and can not handle default values.

IMHO f:translate has to be repaired.

Stefan

Actions #3

Updated by Georg Ringer 6 months ago

  • Status changed from New to Resolved

works fine in 13.2.0-dev

Actions #4

Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF