TYPO3 Agentur Hacks

Aufgabenstellung in unserer Agentur: Wie kann man innerhalb der TYPO3 news Extension (TYPO3 v9) eigene cropVariants (fal_media) anlegen, so dass man selbstgewählte Zuschnittvorlagen / Schnittmasken zur Verfügung hat mit den Seitenverhältnissen 12:1, 8:3 oder beliebige andere? Die Standardlösung, wie Sie z.B. unter https://github.com/georgringer/news/issues/371 zu sehen ist, führte bei uns nicht zum Erfolg.

 

 

Wir benötigten die cropVariants für einen Type, der zuvor angelegt wurde in

 

/typo3conf/ext/DEINEEXTENSION/Configuration/TCA/Overrides/tx_news_domain_model_news.php

 

mit

 

$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['type']['config']['items']['DEINEEXTENSION\DEINHERSTELLER\Domain\Model\DEINTYPENAME'] =$GLOBALS['TCA']['tx_news_domain_model_news']['columns']['type']['config']['items']['DEINEEXTENSION\DEINHERSTELLER\Domain\Model\DEINTYPENAME'] =['DEINE-BESCHREIBUNG, 'DEINEEXTENSION\DEINHERSTELLER\Domain\Model\DEINTYPENAME'] ;

 

In derselben Datei fügen wir dann die gewünschten Varianten hinzu mit (z.B.!)

 

$GLOBALS['TCA']['tx_news_domain_model_news']['types'][''DEINEEXTENSION\DEINHERSTELLER\Domain\Model\DEINTYPENAME']['columnsOverrides']['fal_media']['config'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(

    'fal_media',

    [

                               'overrideChildTca' => ['columns' => ['crop' => ['config' => [ 'cropVariants' => [

                                               'default' => [

                                                               'title' => 'Default',

                                                               'allowedAspectRatios' => [

                                                                                              '16:9' => [

                                                                                                              'title' => '16 zu 9',

                                                                                                              'value' => 16 / 9

                                                                                              ],

                                                                                              '3:2' => [

                                                                                                              'title' => '3 zu 2',

                                                                                                              'value' => 3 / 2

                                                                                              ],

                                                                                              '4:3' => [

                                                                                                              'title' => '4 zu 3',

                                                                                                              'value' => 4 / 3

                                                                                              ],

                                                                                              '1:1' => [

                                                                                                              'title' => '1 zu 1',

                                                                                                              'value' => 1 / 1

                                                                                              ],

                                                                                              '945:275' => [

                                                                                                              'title' => '945 zu 275',

                                                                                                              'value' => 945 / 275

                                                                                              ],

                                                                                              'NaN' => [

                                                                                                              'title' => 'FREI',

                                                                                                              'value' => 0.0

                                                                                              ],

                                                               ],

                                               ],

                               ],],],],],

                ]

);

 

Caches leeren, Reload des Backends und das war's! Gesehen in unserer Agentur in einer Website mit dem CMS TYPO3 9.5.