0
votes

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

1 Answers

3
votes

Hopefully you are using an extension to provide your templates. In this case you can add the following code to 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,
            ]
        ],
    ],
];

This will add the cropVariant demo with:

  • an aspect ratio of 4:3
  • a focus area like you requested with 33% width and height, positioned in the middle of the image
  • a cover area in the bottom of the image

Please note, that this will be applied to all sys_file_reference and not only to CTypes, so pages, news and so on will be also affected.