In order to be able to use lazy loading, I need to modify the src attribute of tt_news’ image output like so:
<img src="/foo/bar/baz.png" … /> // <-- before
<img data-original="/foo/bar/baz.png" … /> // <-- after, no src!
I have tried:
plugin.tt_news.displayList.content_stdWrap {
parseFunc < lib.parseFunc_RTE
HTMLparser = 1
HTMLparser.keepNonMatchedTags = 1
HTMLparser.tags.img.fixAttrib.src.unset = 1
}
but to no avail, since
- The image in question is not being inserted via RTE, but the “normal” media integration.
- That wouldn’t copy the
srcattribute over todata-originalbefore unsetting.
So, what should I do aside from pulling my hair out?
This cannot be solved via typoscript, because the src attribute is hard coded in the cImage function:
The only way I see to modify the src attribute is through a user function. tt_news provides a hook for a user function that allows the custom processing of images (see line 2150 of class.tx_ttnews.php).
Example:
Insert the following typoscript:
Whereas the file user_ttnewsImageMarkerFunc.php contains:
Most of this code is copied from class.tx_ttnews.php. The important line is the following (in each of the two functions):
Then you’ll get the following image tags: