Skip to content

Instantly share code, notes, and snippets.

@fritzmg
Last active August 16, 2019 11:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fritzmg/5fa00ce436a0308f2c7c to your computer and use it in GitHub Desktop.
Save fritzmg/5fa00ce436a0308f2c7c to your computer and use it in GitHub Desktop.
Use fineuploader for news teaser images in Contao

Use fineuploader for news teaser images in Contao

Using these instructions you can replace the default file selector for news teaser images with a direct upload button. This upload button is implemented using the terminal42/contao-fineuploader extension.

First install the extension via the Composer package management for Contao (Packagist: terminal42/contao-fineuploader). Then insert the following content into contao/dca/tl_news.php:

$GLOBALS['TL_DCA']['tl_news']['fields']['singleSRC']['inputType'] = 'fineUploader';
$GLOBALS['TL_DCA']['tl_news']['fields']['singleSRC']['eval'] = [
    'storeFile' => true, 
    'multiple' => false,
    'uploadFolder' => \Contao\Config::get('uploadPath').'/news',
    'addToDbafs' => true,
    'extensions' => \Contao\Config::get('uploadTypes'),
    'doNotOverwrite' => true,
    'mandatory' => true,
];

Important: You also need to make sure, that the subfolder news exists within your files directory! Otherwise the files cannot be moved to this location. If you want to use a different target directory, change the line

'uploadFolder' => \Contao\Config::get('uploadPath').'/news'

accordingly. See the README of the extension for further configuration options.

Note that you will not be able to select existing images anymore when using this direct upload approach. You can only upload new images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment