TYPO3(流体):生成 FAL-SVG-Image 作为内联代码

nti*_*edt 3 typo3 fluid

新的 TS 选项功能是否有流体挂件:#82091 - 允许在 SVG 内容对象中进行内联渲染或解决方法?我看到的唯一解决方案(atm)是编写我自己的viewhelper,或者我错过了一些东西?

小智 7

您可以在根模板中定义一个typoscript对象:

lib.inlineSvg = SVG
lib.inlineSvg {
  renderMode = inline
  src.field = src
}
Run Code Online (Sandbox Code Playgroud)

(参见SVG cObject)。然后在你的液体中你可以这样做:

<f:cObject typoscriptObjectPath="lib.inlineSvg" data="{src: 'path/to/the/file.svg'}" />
Run Code Online (Sandbox Code Playgroud)

当然,这限制了您拥有图像实际路径的情况。您不能(直接)引用 FAL 对象。但是,您可以只获取文件的公共 url:

<f:cObject typoscriptObjectPath="lib.inlineSvg" data="{src: filereference.publicUrl}" />
Run Code Online (Sandbox Code Playgroud)

或者

<f:cObject typoscriptObjectPath="lib.inlineSvg" data="{src: filereference.originalResource.publicUrl}" />
Run Code Online (Sandbox Code Playgroud)

取决于您是否在 Extbase cotext 中(请参阅文档)。data您还可以在 ViewHelper的参数中传递 cObject 所采用的所有其他选项f:cObject(例如宽度)。