is it possible to extend the media type in my typo3 extension? Default fields are alternative, title, desription. How can i add a own field?
$GLOBALS['TCA']['tt_content']['types']['my_slider'] = [
'showitem' => '
--palette--;' . $frontendLanguageFilePrefix . 'palette.general;general,
--palette--;' . $languageFilePrefix . 'tt_content.palette.mediaAdjustments;mediaAdjustments,
pi_flexform,
--div--;' . $customLanguageFilePrefix . 'tca.tab.sliderElements,
assets
',
'columnsOverrides' => [
'media' => [
'label' => $languageFilePrefix . 'tt_content.media_references',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('media', [
'appearance' => [
'createNewRelationLinkTitle' => $languageFilePrefix . 'tt_content.media_references.addFileReference'
],
// custom configuration for displaying fields in the overlay/reference table
// behaves the same as the image field.
'foreign_types' => $GLOBALS['TCA']['tt_content']['columns']['image']['config']['foreign_types']
], $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext'])
]
]
];
if you analyze the datastructure of your TYPO3 database you will find: those fields (
titleandalternative) are not fields in the tablesys_filebut insys_file_metadata(and insys_file_referencefor overwriting them on a specific usage)With that knowledge you can add your fields to these tables and give them a proper rendering and behaviour.
Adding the fields to
sys_file_metadatawill make them available for every file as default values if the fiel is used anywhere.If you want these fields appear only at special usage you need to set the fields only for the table
sys_file_referencewhich is used only for relations between a file and it's usage. AND you need to set conditions to show the fields only if your content elements use a file. This condition might be a litte complicated. if you use inidvidual tables the condition could be used the usage of thisforeign_table, if you usett_contentrecords you also need to include theCTypeof the record in the condition. Probably you will need anuserfunc.Or you have an unique fieldname?