Bug #69516
closedIMG_RESOURCE does not prepend absRefPrefix
Added by Heiko Kromm about 9 years ago. Updated over 8 years ago.
0%
Description
Rendering an imageResource with TypoScript IMG_RESOURCE does not prepend the absRefPrefix. This will cause problems loading images when not using config.baseUrl
Updated by Gerrit Code Review about 9 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43002
Updated by Gerrit Code Review about 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43002
Updated by Heiko Kromm about 9 years ago
Hi Daniel,
you can reproduce the bug with this code:
config { absRefPrefix = / } page = PAGE page.config { xmlprologue = none xhtml_cleaning = all tx_realurl_enable = 1 } page.50 = IMG_RESOURCE page.50.file = fileadmin/images/test.jpg page.50.file.maxH = 100 page.50.stdWrap.wrap = <div style="background-image: url(|); width:100px; height: 100px;" />
It is important, that you have realUrl enabled and then navigate to a page with pagelevel >=2.
e.g.: http://mydomain.tld/level1/level2.html
Then the missing absRefPrefix will cause the browser to search the image at http://mydomain.tld/level1/fileadmin/images/test.jpg and not at http://mydomain.tld/fileadmin/images/test.jpg
Updated by Gerrit Code Review about 9 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43002
Updated by Gerrit Code Review about 9 years ago
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43157
Updated by Paints about 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 23df34dc7bd995a5a7ad5f8ee65cde7c828674b2.
Updated by Ian Solo about 9 years ago
If there's nothing else wrong then the patch for this bug produced another bug.
Now, if imageLinkWrap is used, the absRefPrefix is prepended twice on the link.
By instance, this code:
config.absRefPrefix = / page = PAGE page.10 = IMAGE page.10 { file = /fileadmin/test.png imageLinkWrap = 1 imageLinkWrap { enable = 1 directImageLink = 1 } }
produces:
<a href="//fileadmin/test.png"><img src="/fileadmin/test.png" width="270" height="270" alt="" border="0"></a>
notice the double / at the begin of the href.
The second slash is added by line 5934 of ContentObjectRenderer.php:
$this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix . $link_param;
Updated by Markus Klein about 9 years ago
- Status changed from Resolved to Needs Feedback
- Assignee deleted (
Heiko Kromm) - % Done changed from 100 to 0
The patch needs to be reverted with #71435 as it introduces way too many side-effects.
The usecase described above is an edge-case, where the regular replacement heuristics (double-quote + foldername, eg. "fileadmin) does not apply.
To fix the issue one could modify \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::setAbsRefPrefix() to also e.g. include single quotes.
Updated by Alexander Opitz over 8 years ago
How to proceed here? Close as not fixable?
Updated by Markus Klein over 8 years ago
- Status changed from Needs Feedback to Rejected
As already written there is no way to retrieve an absolute path from IMG_RESOURCE. You may change your TS to apply the absRefPrefix manually, which always works except with CMS 7 with absRefPrefix=auto.
We could extend the absRefPrefix handling to replace also single-quoted occurrences, but this is a high-risk thingy for released versions, we could do that for CMS 8 only.
Nowadays we usually use a fluid template, where the image viewhelpers are able to return an absolute path, so this is not an issue there.