typo3typo3-7.x

How to modify the TCA ImageManipulation configuration of a FAL reference?


In TYPO3 7.4 I have the following TCA configuration for uploading a single image with the new ImageManipulation (crop tool) enabled:

'single_image_field' => array(
    'exclude' => 1,
    'label' => 'LLL:EXT:myext/Resources/Private/Language/locallang_db.xlf:sometable.single_image_field',
    'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
        'single_image_field',
        array(
            'maxitems' => 1,
            'appearance' => array(
                'collapseAll'   => 1,
                'expandSingle'  => 1,
            ),
            'foreign_types' => array(
                \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => array(
                    'showitem' => '--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette'
                ),
            )
        ),
        'jpg,jpeg,png'
    ),
),

Now I like to have my custom aspect ratio's configured. This seems possible with the TCA configuration of column type: ImageManipulation (see: https://wiki.typo3.org/TYPO3.CMS/Releases/7.2/Feature#Impact_9).

But how can I apply this in the above configuration?


Solution

  • The default crop aspect ratio's for sys_file_reference can be overwritten as follows:

    $GLOBALS['TCA']['sys_file_reference']['columns']['crop']['config']['ratios'] = array(
        '1.7777777777777777' => '16:9',
        '1.3333333333333333' => '4:3',
        '1' => '1:1',
        'NaN' => 'Free',
    );