Building a TYPO3 extension in Extbase/Fluid

Add file fields using the FAL (File Abstraction Layer): reference multiple images (yourPictures)

In contrast to adding a single file reference you must set up ObjectStorage instead of FileReference in order to add a variable number of file references.

File paths are relative to the root of your extension /typo3conf/ext/your_extension/

/Classes/Domain/Model/YourModel.php

<?php
        /**
         * yourPictures
         *
         * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
         * @lazy
         */

        protected $yourPictures = NULL;

        /**
         * Constructor
         *
         * @return AbstractObject
         */

        public function __construct() {
                // ObjectStorage is needed to reference multiple files to one field
                // see also @var before variable and @return before the respective get() method
                $this->yourPictures = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        }

        /**
         * returns yourPictures
         *
         * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
         */

        public function getYourPictures() {
                return $this->yourPictures;
        }

        /**
         * sets yourPictures
         *
         * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $yourPictures
         * @return void
         */

        public function setYourPictures($yourPictures) {
                $this->yourPictures = $yourPictures;
        }
?>
        }
?>

/Configuration/TCA/YourModel.php

array 'types' ››› see topic Add properties to your domain model (fields just have to be named with no further statements)

array 'columns' ›››

'your_pictures' => array(
        'exclude' => 1,
        'label' => 'LLL:EXT:your_ext/Resources/Private/Language/locallang_db.xlf:tx_yourext_domain_model_yourmodel.your_pictures',
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
                'yourPictures',
                array('minitems'=>0,'maxitems'=>10),
                $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
        ),
),
        ),
),

$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] contains a comma-separated list of allowed file extensions

/ext_tables.php and localisation files

see topic Add properties to your domain model

/ext_tables.sql

add my_pictures varchar(255) DEFAULT '' NOT NULL,
NOTE: this MUST be a varchar although it contains only the number of referenced files!

Fluid Template

<f:for each="{yourDomain.myPictures}" as="pic">
        <f:image src="{pic.originalResource.publicUrl}" alt="{pic.originalResource.alternative}" title="{pic.originalResource.title}" ></f:image>
        {pic.originalResource.description}
</f:for>
        {pic.originalResource.description}
</f:for>