[TYPO3-core] $GLOBALS['TSFE']->page using relative path to /uploads/media/ in media field instead of references

Patrick Broens patrick.broens at typo3.org
Tue Oct 1 13:51:47 CEST 2013


Hi,

Currently I'm writing documentation to show best practices how to use
TypoScript together with FAL, based on master 6.2-dev. Almost directly
at the beginning of this writing, I stumbled upon something curious.

Since the introduction of FAL, the media field of the pages table is no
longer using /uploads/media/, but contains references to FAL records.
However, when $GLOBALS['TSFE']->page is constructed, the media field
contains the files with a relative path back two directories in its path
(../../fileadmin/etcetera)

The following TypoScript describes this problem very well:

elements.image = IMAGE
elements.image {
    file {
        import = /uploads/media/
        import {
            data = field:media
            listNum = 0
        }
    }
}

or use "field = media" instead of "data = field:media"

When removing the 'import = /uploads/media/' property, it fails to load
the image. However, you can put whatever you want in 'import' as long as
it contains two directories like /foo/bar/. (ContentObjectRenderer
getImgResource()) This makes no sense at all and is hard to explain to
users that you need to use the "import" property although not used anymore.

IMHO the "media" field in $GLOBALS['TSFE']->page should contain the file
references and not the paths. If so, you can use the treatIdAsReference
property in the TypoScript above, like you can do with levelmedia:

elements.image = IMAGE
elements.image {
    file {
        import {
            data = levelmedia:-1, slide
            listNum = 0
        }
        treatIdAsReference = 1
    }
}

I was wondering, was this done on purpose? Does anyone know if there are
drawbacks when we change this behaviour and especially the contents of
the media field? Both TypoScript parts should handle file relations the
same way, but do not.

-- 
Patrick Broens

TYPO3 .... inspiring people to share!
Get involved: typo3.org


More information about the TYPO3-team-core mailing list