How to get all images from folder in typo3

For get list of all images from folder you have first read all files from folder.

Click here for more detail about how to get all files list from folder in typo3

$folderPath = "fileadmin/images/"

$files = \TYPO3\CMS\Core\Utility\GeneralUtility::getFilesInDir($folderPath, '', true, 1, '');

From above script you will get all files list from your folder.

Now we only need to get image or any selected extension files

for that we have to use following script for get particular extension file.

if (count($files) > 0) {

    foreach ($files as $key => $image) {
        $pathinfo = pathinfo($image);

        if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('gif,png,jpeg,jpg', strtolower($pathinfo['extension']))) {
            $images[$key] = $image;

Note : gif,png,jpeg,jpg is a file extension.

You will get all selected file list in “$images” array.

Note : if you want only PDF file then you have to write “pdf” instead of all image extension like : jpe, png, gif etc.

whatever particuler file you want just set extension in inList function.

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s