TYPO3 (Fluid): Generate FAL-SVG-Image as inline code

Viewed 798
1 Answers

You can define a typoscript object in your root template:

lib.inlineSvg = SVG
lib.inlineSvg {
  renderMode = inline
  src.field = src
}

(see SVG cObject). Then in your fluid you can do this:

<f:cObject typoscriptObjectPath="lib.inlineSvg" data="{src: 'path/to/the/file.svg'}" />

Of course this limits you to cases in which you have the actual path to the image. You cannot (directly) reference a FAL object. You can, however, just get the files public url:

<f:cObject typoscriptObjectPath="lib.inlineSvg" data="{src: filereference.publicUrl}" />

or

<f:cObject typoscriptObjectPath="lib.inlineSvg" data="{src: filereference.originalResource.publicUrl}" />

depending on whether you are in Extbase cotext or not (see the documentation). You can also pass all other options the cObject takes in the data argument of the f:cObject ViewHelper (e.g. width).

Related