【问题标题】:TYPO3 Fluid FAL images get wrong path if I will show it as background image如果我将 TYPO3 Fluid FAL 图像显示为背景图像,则其路径错误
【发布时间】:2016-12-12 00:07:57
【问题描述】:

您好,我正在使用 FluidTYPO3 和最新的 TYPO3 Core 7.6 和 Flux/Fluid Extensions。

我正在使用 FAL 关系:

<flux:field.inline.fal name="backgroundimage" minItems="1" maxItems="1" />

现在我可以使用以下 sn-p 在前端显示我的图片(for/each 已过时,我只有一张图片):

<f:for each="{v:content.resources.fal(field: 'backgroundimage')}" as="image">
    <f:image treatIdAsReference="1" src="{image.id}" alt=""/><br/>
</f:for>

图像会像&lt;img src="fileadmin/user_upload/.."一样渲染

但我需要我的图片作为背景图片,所以我尝试了:

<f:for each="{v:content.resources.fal(field: 'backgroundimage')}" as="image">
 <div class="back" style="background-image: url('{image.id}');"></div>
</f:for>

但我会得到..&lt;div class="back" style="background-image: url('1:/Editors_English/image.jpg');"&gt;&lt;/div&gt;

我认为treatIdAsReference 不见了,但它是如何工作的?我不知道..谢谢你的帮助。

【问题讨论】:

    标签: typo3 background-image fluid typo3-7.6.x fal


    【解决方案1】:

    您需要执行与 &lt;img&gt;-tag 中的图像基本相同的操作:使用 ViewHelper 为您呈现图像 URL。在这种情况下,您只需要 URL,周围没有 &lt;img&gt; 标记,因此您必须改用 ViewHelper f:uri.image。在内联符号中使用它也很有帮助,如下所示:

    <f:for each="{v:content.resources.fal(field: 'backgroundimage')}" as="image">
      <div class="back" style="background-image: url('{f:uri.image(src: image.id, treatIdAsReference: 1)}');"></div>
    </f:for>
    

    我不确定您是否真的需要 treatIdAsReference 参数,您可以省略它。

    【讨论】:

    • 谢谢乔斯特。它工作完美。 treatIdAsReference这个参数不是必须的,没错。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-30
    • 2020-05-15
    • 1970-01-01
    • 1970-01-01
    • 2015-04-20
    • 2011-02-04
    • 2016-01-28
    相关资源
    最近更新 更多