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

问题描述

新的 TS 选项 Feature: #82091 - Allow inline rendering in SVG content object 是否有流体垂饰或解决方法? 我看到的唯一解决方案(atm)是编写我自己的视图助手,否则我错过了什么?

解决方法

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

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

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

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

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

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

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

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