Bug #77722

absRefPrefix is not applied everywhere

Added by Robert Vock about 5 years ago. Updated 10 months ago.

Should have
Start date:
Due date:
% Done:


Estimated time:
TYPO3 Version:
PHP Version:
Is Regression:
Sprint Focus:


When I've set absRefPrefix, it is not set everywhere. One example is the srcset-attribute:

<img src="fileadmin/example.png" srcset="fileadmin/example.png 200w, fileadmin/example_400.png 400w">

gets converted to

<img src="/fileadmin/example.png" srcset="/fileadmin/example.png 200w, fileadmin/example_400.png 400w">

(only the first fileadmin in the srcset got replaced)

This happens because TypoScriptFrontendController::setAbsRefPrefix() just searches for "fileadmin as a simplification of finding attributes which start with a relative path.

One improvement would be to add the absRefPrefix in the getPublicUrl() method of ResourceStorage, if relativeToCurrentScript is false:

Then images which are used within srcset will already have the correct path. Of course this does not fix all missing prefixes, but at least all where FAL is used.

Related issues

Related to TYPO3 Core - Bug #72164: "absRefPrefix = auto" does not work if PageGenerator is not usedClosed2015-12-11

Related to TYPO3 Core - Bug #82486: IncludeJS* / includeCSS* (including compression / concatenation) ignoring absRefPrefixClosed2017-09-14

Related to TYPO3 Core - Bug #82574: Inconsistent support of config.absRefPrefix in fluid/extbaseNew2017-09-28


Updated by Benni Mack about 5 years ago

I would suggest that the fix is, that it searches for all local storages and takes their prefixes and searches through them in the same place - what do you think?


Updated by Robert Vock about 5 years ago

The method TypoScriptFrontendController::setAbsRefPrefix() already loops over the storages and sets the absRefPrefix for all folders:

There it performs a simple str_replace, where it takes the prefix of each storage and prepends a quote. So it searches for "fileadmin instead of only fileadmin. This works in most cases, when the path directly appears in an attribute, but not when it appears at other places.

It's not possible to perform a simple str_replace, when you leave the quote, because you would also replace fileadmin where it already is prepended by a prefix or a domain. I think this would quickly introduce new bugs. That's why I would only change the getPublicUrl()-method of ResourceStorage. If the introduces coupling between ResourceStorage and TSFE is undesired, there could be a hook like emitPostGeneratePublicUrlSignal and TSFE fixes the paths within the hook.


Updated by Ernesto Baschny about 5 years ago

  • Status changed from New to Needs Feedback

Robert Vock, the original css_styled_content implementation of responsive images uses the cImage method, which calls ContentObjectRenderer::getImageSourceCollection which will take care of adding the absRefPrefix before each link before rendering. I am not sure how you ended up with the srcset without the absRefPrefix. Maybe you are not using the cImage API? Could you elaborate on that?


Updated by Robert Vock about 5 years ago

I am using Smarty as template engine, and work directly with FileReference-Objects within the template and call their getPublicUrl-method ;)

But either way, it's not restricted to srcset. Anywhere, where an integrator uses the publicUrl, and it is not at the start of an attribute, absRefPrefix will not work.

Another example is a background image:

lib.backgroundImage = IMG_RESOURCE
lib.backgroundImage.file.import.data = levelmedia:-1, slide
lib.backgroundImage.file.import.listNum = 0
lib.backgroundImage.file.treatIdAsReference = 1
lib.backgroundImage.stdWrap.wrap (
  <div style="background-image:url('|');" class="page-background"></div>

page.20 < lib.backgroundImage

Here the publicUrl is not prefixed with the absRefPrefix.

Other examples might be, if you want to output a url within JavaScript, which gets generated by TypoScript.


Updated by Josef Glatz about 5 years ago

I also discovered the problem in TYPO3 8.4.0-dev (master) within the `f:uri.resource` view helper. Is this intentionally, or even a relevant error?


Updated by Christian Toffolo almost 5 years ago

I also encountered this bug setting in a Fluid partial:

style="background-image: url('{f:cObject(typoscriptObjectPath: 'lib.imagePlaceholderFluid', data: {image: item.backgroundImage.0.uid})}');" 

The single quote after
make function setAbsRefPrefix() to fail to add the absRefPrefix.


Updated by Alexander Opitz over 4 years ago

  • Status changed from Needs Feedback to New
  • Target version set to Candidate for patchlevel
  • TYPO3 Version changed from 8 to 6.2

Updated by David Bruchmann over 4 years ago

Depending on need the usage of absRefPrefix might be wrong here.
IMO there should be either a parameter if absRefPrefix shall be prepended or a second variable including the merged path.
As the usage is in different places perhaps the parameter solution is easier in realization and usage.
So a general approach to change the paths without options is wrong in my opinion.


Updated by DANIEL Rémy almost 4 years ago

  • Related to Bug #82486: IncludeJS* / includeCSS* (including compression / concatenation) ignoring absRefPrefix added

Updated by Riccardo De Contardi over 3 years ago

  • Related to Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9 added

Updated by Oliver Hader over 3 years ago

  • Related to deleted (Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9)

Updated by Riccardo De Contardi almost 2 years ago

I tried to repeat the test reported on #82486 on a 9.5.10 TYPO3 installation, i.e.

1) TS Setup

config {
  absRefPrefix = /foo/
  compressJs = 1

page = PAGE
page {
  10 = TEXT
  10.value = HELLO WORLD!
  # setting a link to test if absRefPrefix works
  10.typolink.parameter = 1

  includeJSLibs.js1 = fileadmin/js1.js
  includeJSLibs.js2 = fileadmin/js2.js

  includeCSS.css1 = fileadmin/css1.css
  includeCSSLibs.css1 = fileadmin/css1.css


The files are prepended with the /foo prefix:

<link rel="stylesheet" type="text/css" href="/foo/fileadmin/css1.css?1571951025" media="all">
<link rel="stylesheet" type="text/css" href="/foo/fileadmin/css1.css?1571951025" media="all">

<script src="/foo/typo3temp/assets/compressed/js1-073ad306084932e4f6f8cc94ecc220df.js?1571951083" type="text/javascript"></script>
<script src="/foo/typo3temp/assets/compressed/js2-5902d8a0726c46b4d9e425058757d08c.js?1571951083" type="text/javascript"></script>

while the HELLO WORLD! link is not (ID=1 is my homepage, but the result does not change with choosing another page):

<a href="/">HELLO WORLD!</a>

Updated by Riccardo De Contardi almost 2 years ago

  • Related to Bug #82574: Inconsistent support of config.absRefPrefix in fluid/extbase added

Updated by Marc Hirdes 10 months ago

Any workaround? I really need this. A customer imports the HTML and needs absolute paths.

Also available in: Atom PDF