'TYPO3: How to render images with absolute path in Ajax calls?

When I generate an image in a TYPO3 11 extension which is not based on Extbase/Fluid, then this is accomplished by a call (tt_products):

$imageCode = $cObj->getContentObject($contentObject)->render($imageConf);

This will result in a HTML code:

<img src="/fileadmin/_processed_/6/8/image__aaa05df7b9.gif" width="171" height="100" alt="" border="0">

However when I use an Ajax call with the same method, then the returned code is without an absolute path starting with "/":

<img src="fileadmin/_processed_/6/8/image__aaa05df7b9.gif" width="171" height="100" alt="" border="0">

Therefore no image will be found under the following link of a current page "http://example.com/mypage/mysubpage"!

The file http://example.com/mypage/mysubpage/fileadmin/_processed_/6/8/image__aaa05df7b9.gif does not exist

The image is not there but here:

 http://example.com/fileadmin/_processed_/6/8/image__aaa05df7b9.gif

What is missing on the Ajax side?

The image setup is taken from tt_products setup.txt

A feature "forceAbsoluteUrl = 1" is needed.

See Feature: #64286



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source