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.