简体   繁体   中英

TYPO3 modyfing img source on tt_news list item

I'm trying to add additional parameter to tt_news img list source: data-src="path-to-img" . Is it possible? I try with generic marker but without any success:

plugin.tt_news.genericmarkers {
  data = imgsource
  imgsource = TEXT
  imgsource {
    field = image
    wrap = <img src="uploads/pics/|" data-src="uploads/pics/|" />
    file.maxW = 112
    file.maxH = 124
  }
}

But on output I only have this in source: <img src="uploads/pics/img.jpg" data-src="uploads/pics/ without second img source, img size and close tag.

Any suggestions?

Some remarks before I show you an example:

  • the »wrap« property only allows one pipe (TYPO3 is replacing the first »|« character with the current value), that why your second parameter is empty
  • the TEXT objekt only allows value and all properties listed in the »stdWrap« section (see TEXT object: http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Text/Index.html , list of all stdWrap-properties http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Stdwrap/Index.html )
  • so TEXT does have properties like »wrap« or »case« or »substring«, but no »file«
  • what you want is an IMAGE object, which allows to manipulate images

     plugin.tt_news.genericmarkers { imgsource = IMAGE imgsource { file.import = uploads/pics/ file.import.field = image file.import.listNum = 0 file.width = 250 # if you just want to link the original image params.field = image params.wrap = data-src="/uploads/pics/|" /* # if you want want to manipulate the image as well, then use this code instead # IMG_RESOURCE is almost the same as IMAGE, but returns only the path to the resulting image, not the »<img src="">«-Markup params.cObject = IMG_RESOURCE params.cObject { file.import = uploads/pics/ file.import.field = image file.import.listNum = 0 file.width = 500 stdWrap.wrap = data-src="|" } */ } } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM