如何仅为一种特定的 ctype 设置裁剪变体?

问题描述 投票:0回答:1

我想为不同的内容元素设置不同的cropVariants。

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

这适用于像文本媒体这样的标准 ctypes,但不适用于我自己的内容元素。有人知道问题出在哪里吗?

typo3
1个回答
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!

© www.soinside.com 2019 - 2024. All rights reserved.