typo3fal

Restrict page media allowedExtensions TYPO3 9.5.x


How can I restrict allowedExtention just for $GLOBALS['TCA']['pages']['columns']['media']? But not using $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] as it will add restriction for all FAL fields.

I found class

class ImageManipulationElement extends AbstractFormElement
{
    /**
     * Default element configuration
     *
     * @var array
     */
    protected static $defaultConfig = [
        'file_field' => 'uid_local',
        'allowedExtensions' => null, // default: $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']

Looks like should be something like:

$GLOBALS['TCA']['pages']['columns']['media']['config']['overrideChildTca']['allowedExtensions'] = 'jpg, jpeg';

Hard way will drope all usefull things for this field.

$GLOBALS['TCA']['pages']['columns']['media'] = [
             'exclude' => true,
             'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.media',
             'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
                 'media',
                 [], 'jpg, jpeg'
             )
         ]; 

So not is our way. I need just some override like

$GLOBALS['TCA']['pages']['columns']['media']['config']['overrideChildTca']['columns']...['allowedExtention'] = 'jpg, jpeg';

Who know knows how to do this?


Solution

  • After small searching I found this example:

    $allowExtensions = 'jpg,jpeg';
    $GLOBALS['TCA']['pages']['columns']['media']['config']['filter'][0]['parameters']['allowedFileExtensions'] = '$allowExtensions; 
    $GLOBALS['TCA']['pages']['columns']['media']['config']['overrideChildTca']['columns']['uid_local']['config']['appearance']['elementBrowserAllowed']= $allowExtensions;
    

    added to typo3conf/ext/myext/Configuration/TCA/Overrides/pages.php