How to set focusArea for all ctypes

限于喜欢 提交于 2020-01-16 09:07:12

问题


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:


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.



来源:https://stackoverflow.com/questions/44542096/how-to-set-focusarea-for-all-ctypes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!