如何只为一个特定的ctype设置focusArea?

时间:2017-06-27 11:16:53

标签: typo3

我想为不同的内容元素设置不同的焦点区域(cropVariants)。

我在这里找到了一个解决方案:https://docs.typo3.org/typo3cms/extensions/core/8.7/Changelog/8.6/Feature-75880-ImplementMultipleCroppingVariantsInImageManipulationTool.html

这适用于像textmedia这样的标准ctypes,但不适用于我自己的内容元素。有没有人知道问题可能是什么?

1 个答案:

答案 0 :(得分:2)

正如我通过Slack通道发现的那样,您可以通过覆盖TCA来实现这一目的:

<?php

$originalTtContent = $GLOBALS['TCA']['tt_content'];
$overridesForTtContent = [
  'types' => [
    'ENTER_YOUR_CTYPE' => [
      'columnsOverrides' => [
        'ENTER_YOUR_IMAGE_FIELD' => [
          'config' => [
            'overrideChildTca' => [
              'columns' => [
                'crop' => [
                  'config' => [
                    'cropVariants' => [
                      'CROPVARIANT_TO_DISABLE' => [
                        'disabled' => true,
                      ],
                      'YOUR_NEW_CROPVARIANT' => [
                        'title' => 'YOUR_NEW_CROPVARIANT',
                        'allowedAspectRatios' => [
                          '1:1' => [
                            'title' => 'Square',
                            'value' => 1 / 1
                          ],
                        ],
                        'selectedRatio' => '1:1',
                        'cropArea' => [
                          'x' => 0.0,
                          'y' => 0.0,
                          'width' => 1.0,
                          'height' => 1.0,
                        ],
                      ],
                    ],
                  ],
                ],
              ]
            ]
          ]
        ]
      ]
    ]
  ]
];
$GLOBALS['TCA']['tt_content'] = array_merge_recursive($originalTtContent, $overridesForTtContent);

感谢@ kevin-appelt!