如何获取位于我的扩展 "Resources/Public" 文件夹中的文件的 FAL 对象?

How to get a FAL object of a file located in my extensions "Resources/Public" folder?

在我的扩展 Resource/Public 文件夹中,我有一张图片。我想使用 <f:image>-ViewHelper 渲染此图像,使用 image-attribute,它采用 FAL 文件对象。我该怎么做?

不是我不能使用src,我只是不想-我的代码中少了一个分支。

我正在使用 TYPO3 6.2.14 和 FluidTYPO3 生态系统。

我在 Slack 中得到了 Helmut Hummel 的回答:只有在使用兼容层时才有可能。

他写了一篇关于这个的 blog post。相关部分是这样的:

Static Resources

I would define only two rules for how to (currently) use static resources:

  • Don’t use them with the image view helper
  • Put them into an extension in the Resources/Public folder

If you follow these rules, you will have less trouble.

We currently don’t have an API to deal with static resources and the FAL API can only deal with them in a backwards compatibility layer (which you should avoid using, really!). This is why you should currently follow rule 1 (Once we have objects that describe static resources properly, we might abondon rule 1).

You need to follow rule 2 to take advantage of a not well known Fluid view helper, the resource uri view helper. You can use it to e.g. show an image from a site package (my_site/Resources/Public/Images/logo.png) like that:

<img src="{f:uri.resource(path:'Images/logo.png', extensionName:'my_site')}" width="200" />

Note that I didn’t use the image view helper here, but the plain img html tag and used the resource view helper in inline notation to automatically calculate the path to the web root for that image. Also note, that the view helper expects the static resources to be placed in the Resources/Public directory.