ntiedt
ntiedt

Reputation: 183

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

Is there a fluid pendant to the new TS option Feature: #82091 - Allow inline rendering in SVG content object or a workaround? The only solution i see(atm) is to write my own viewhelper or i am missed something?

Upvotes: 3

Views: 2342

Answers (1)

Johannes Nielsen
Johannes Nielsen

Reputation: 177

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).

Upvotes: 7

Related Questions