Project

General

Profile

Actions

Bug #69516

closed

IMG_RESOURCE does not prepend absRefPrefix

Added by Heiko Kromm over 8 years ago. Updated almost 8 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-09-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Rendering an imageResource with TypoScript IMG_RESOURCE does not prepend the absRefPrefix. This will cause problems loading images when not using config.baseUrl


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #70718: cObj imageLinkWrap with absRefPrefix and linkParams result in wrong URLClosed2015-10-14

Actions
Related to TYPO3 Core - Bug #71435: Revert of #69516 - [BUGFIX] IMG_RESOURCE does not prepend absRefPrefixClosed2015-11-09

Actions
Actions #1

Updated by Gerrit Code Review over 8 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

Actions #2

Updated by Markus Sommer over 8 years ago

  • Assignee set to Heiko Kromm
Actions #3

Updated by Gerrit Code Review over 8 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

Actions #4

Updated by Heiko Kromm over 8 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

Actions #5

Updated by Gerrit Code Review over 8 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

Actions #6

Updated by Gerrit Code Review over 8 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

Actions #7

Updated by Paints over 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #8

Updated by Christian Toffolo over 8 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;

Actions #9

Updated by Markus Klein over 8 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.

Actions #10

Updated by Alexander Opitz about 8 years ago

How to proceed here? Close as not fixable?

Actions #11

Updated by Markus Klein almost 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.

Actions

Also available in: Atom PDF