How to set focusArea for all ctypes

时间:2017-06-14 10:27:07

标签: typo3

Here i found the information how to set global crop variants for all ctypes.

https://docs.typo3.org/typo3cms/extensions/core/8.7/Changelog/8.7/Feature-79812-AllowOverridingCropVariantsForImageManipulation.html

Now i want to set a focusArea for all ctypes. What would be the best way?

'focusArea' => [
                'x' => 1 / 3,
                'y' => 1 / 3,
                'width' => 1 / 3,
                'height' => 1 / 3,
            ],

https://docs.typo3.org/typo3cms/extensions/core/8.7/Changelog/8.6/Feature-75880-ImplementMultipleCroppingVariantsInImageManipulationTool.html

1 个答案:

答案 0 :(得分:3)

希望您使用扩展程序来提供模板。在这种情况下,您可以将以下代码添加到your_extension/Configuration/TCA/Overrides/sys_file_reference.php

$GLOBALS['TCA']['sys_file_reference']['columns']['crop']['config']['cropVariants'] = [
    'demo' => [
        'title' => 'Demo',
        'allowedAspectRatios' => [
            '4:3' => [
                'title' => '4:3',
                'value' => 4 / 3
            ],
        ],
        'selectedRatio' => '4:3',
        'cropArea' => [
            'x' => 0.0,
            'y' => 0.0,
            'width' => 1.0,
            'height' => 1.0,
        ],
        'focusArea' => [
            'x' => 1 / 3,
            'y' => 1 / 3,
            'width' => 1 / 3,
            'height' => 1 / 3,
        ],
        'coverAreas' => [
            [
                'x' => 0.05,
                'y' => 0.85,
                'width' => 0.9,
                'height' => 0.1,
            ]
        ],
    ],
];

这会将cropVariant demo添加到:

  • 纵横比为4:3
  • 您要求的焦点区域,宽度和高度均为33%,位于图像中间
  • 图像底部的封面区域

请注意,这将适用于所有sys_file_reference而不仅适用于CTypes,因此页面,新闻等也会受到影响。