如何将cropVariants添加到TYPO3 flexform

时间:2017-11-29 13:41:15

标签: typo3 typo3-8.x

我可以覆盖TCA中图像字段的cropVaraints,如下所示:

'columnsOverrides' => [
    'image' => [
        'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_be.xlf:general.field.image',
        'config' => [
            'overrideChildTca' => [
                'columns' => [
                    'crop' => [
                        'config' => [
                            'cropVariants' => [
                                'default' => [
                                    'title' => 'LLL:EXT:myext/Resources/Private/Language/locallang_be.xlf:wizard.banner.title',
                                    'allowedAspectRatios' => [
                                        '2:1' => [
                                            'title' => 'LLL:EXT:myext/Resources/Private/Language/locallang_be.xlf:field.banner.image-crop.ratio',
                                            'value' => 2 / 1
                                        ],
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ],
],

我试图将其用于灵活变形 - 但没有任何成功。所以我需要的是这样的东西(但工作:-))

<foreign_selector_fieldTcaOverride type="array">
    <config>
        <appearance>
            <elementBrowserType>file</elementBrowserType>
            <elementBrowserAllowed>jpg,png</elementBrowserAllowed>
        </appearance>
        <overrideChildTca>
            <columns>
                <crop>
                    <config>
                        <cropVariants>
                            <default>
                                <title>Blubber</title>
                                <allowedAspectRatios>
                                    <test>
                                        <title>2:1</title>
                                        <value>2 / 1</value>
                                    </test>
                                </allowedAspectRatios>
                            </default>
                        </cropVariants>
                    </config>
                </crop>
            </columns>
        </overrideChildTca>
    </config>
</foreign_selector_fieldTcaOverride>

之前有人这样做过吗?

如果不可能,也许我可以获得灵活变形?我目前有一个图像字段的gridelement。

[UPDATE] 正如@fnagel指出应该可以覆盖默认值,所以我尝试将以下内容放入我的Overrides / sys_file_reference.php中 - 但它没有效果 - 我甚至无法在TCA-Inspector中找到该默认定义...

$GLOBALS['TCA']['sys_file_reference']['columns']['crop']['config‌']['cropVariants‌​']['default'] = [
    'title' => 'LLL:EXT:al_template/Resources/Private/Language/locallang_be.xlf:wizard.gallery.title',
    'allowedAspectRatios' => [
        'NaN' => [
            'title' => 'LLL:EXT:al_template/Resources/Private/Language/locallang_be.xlf:field.gallery.image-crop.ratio',
            'value' => 0.0
        ],
    ],
];
写作ot也没有效果......

 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule(
    $GLOBALS['TCA']['sys_file_reference'],
    [
        'columns' =>[
            'crop' => [
                'config‌' => [
                    'cropVariants‌​' => [
                        'default'=> [
                            'title' => 'LLL:EXT:al_template/Resources/Private/Language/locallang_be.xlf:wizard.gallery.title',
                            'allowedAspectRatios' => [
                                'NaN' => [
                                    'title' => 'LLL:EXT:al_template/Resources/Private/Language/locallang_be.xlf:field.gallery.image-crop.ratio',
                                    'value' => 0.0
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ],
    ]
);

有没有成功设置的人?

2 个答案:

答案 0 :(得分:5)

要在flexform中允许图像处理,您必须通过overrideChildTca属性启用它。

flexform示例:

        <background_image type="array">
            <TCEforms>
                <label>LLL:EXT:myext/Resources/Private/Language/Backend.xlf:background_image
                </label>
                <config>
                    <type>inline</type>
                    <minitems>1</minitems>
                    <maxitems>1</maxitems>
                    <appearance type="array">
                        <createNewRelationLinkTitle>LLL:EXT:cms/locallang_ttc.xlf:media.addFileReference
                        </createNewRelationLinkTitle>
                        <enabledControls type="array">
                            <delete>1</delete>
                            <dragdrop>1</dragdrop>
                            <hide>1</hide>
                            <info>1</info>
                            <localize>1</localize>
                        </enabledControls>
                        <headerThumbnail type="array">
                            <field>uid_local</field>
                            <height>45c</height>
                            <width>45</width>
                        </headerThumbnail>
                        <useSortable>1</useSortable>
                        <showAllLocalizationLink>0</showAllLocalizationLink>
                        <showPossibleLocalizationRecords>0</showPossibleLocalizationRecords>
                        <showRemovedLocalizationRecords>0</showRemovedLocalizationRecords>
                        <showSynchronizationLink>0</showSynchronizationLink>
                    </appearance>
                    <behaviour type="array">
                        <localizationMode>select</localizationMode>
                        <localizeChildrenAtParentLocalization>1</localizeChildrenAtParentLocalization>
                    </behaviour>
                    <foreign_field>uid_foreign</foreign_field>
                    <foreign_label>uid_local</foreign_label>
                    <foreign_match_fields type="array">
                        <fieldname>media</fieldname>
                    </foreign_match_fields>
                    <foreign_selector>uid_local</foreign_selector>
                    <foreign_selector_fieldTcaOverride type="array">
                        <config type="array">
                            <appearance type="array">
                                <elementBrowserAllowed></elementBrowserAllowed>
                                <elementBrowserType>file</elementBrowserType>
                            </appearance>
                        </config>
                    </foreign_selector_fieldTcaOverride>
                    <foreign_sortby>sorting_foreign</foreign_sortby>
                    <foreign_table>sys_file_reference</foreign_table>
                    <foreign_table_field>tablenames</foreign_table_field>
                    <overrideChildTca>
                        <types type="array">
                            <numIndex index="0" type="array">
                                <showitem>
                                    --palette--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                    --palette--;;filePalette
                                </showitem>
                            </numIndex>
                            <numIndex index="1" type="array">
                                <showitem>
                                    --palette--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                    --palette--;;filePalette
                                </showitem>
                            </numIndex>
                            <numIndex index="2" type="array">
                                <showitem>
                                    --palette--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                    --palette--;;filePalette
                                </showitem>
                            </numIndex>
                            <numIndex index="3" type="array">
                                <showitem>
                                    --palette--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.audioOverlayPalette;audioOverlayPalette,
                                    --palette--;;filePalette
                                </showitem>
                            </numIndex>
                            <numIndex index="4" type="array">
                                <showitem>
                                    --palette--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.videoOverlayPalette;videoOverlayPalette,
                                    --palette--;;filePalette
                                </showitem>
                            </numIndex>
                            <numIndex index="5" type="array">
                                <showitem>
                                    --palette--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
                                    --palette--;;filePalette
                                </showitem>
                            </numIndex>
                        </types>
                    </overrideChildTca>
                </config>
            </TCEforms>
        </background_image>

启用后,您可以通过TsConfig定义自定义比率:

TCEFORM.sys_file_reference.crop.config.cropVariants {
  default {
    title = LLL:EXT:lang/Resources/Private/Language/locallang_wizards.xlf:imwizard.ratio.free
    selectedRatio = NaN
    allowedAspectRatios {
      NaN {
        title = free
        value = 0.0
      }
    }
  }
}

适用于TYPO3 8 LTS

答案 1 :(得分:2)

不可能afaik。您需要设置一个总体默认值,并使用TCA为所有其他元素调整它。