Search code examples
phpcontent-management-systemcontao

How to get actual image path in Contao template


Add an extra field for fileupload. But the data getting in template is a set of special characters. How to get the original path?

My code:

$GLOBALS['TL_DCA']['tl_news']['fields']['image'] = array
(
    'label'                   => &$GLOBALS['TL_LANG']['tl_news']['quoteperson_image'],
    'exclude'                 => true,
    'filter'                  => true,
    'inputType'               => 'fileTree',
    'eval'                    => array('tl_class'  => 'clr','files' => true,'fieldType' =>'checkbox',),
     'sql'                    => "blob NULL",
);

Solution

  • The data returned by the fileTree widget is a binary UUID. In order to get the original path you can do the following for example:

    $objFile = \Contao\FilesModel::findByUuid($uuid);
    $strPath = $objFile->path;