1

In a fluid template, I would like to output a linked file's size.

I'm using f:link.page to link to the file, as I think this is the way to do it (please correct if not).

<f:link.page class="download" pageUid="fileadmin/redaktion/download/papers/{paper.download}" {paper.author}">PDF</f:link.page>

As I'm already using the extension ml_links on the site, I thought I could pass the link through lib.parseFunc_RTE, but

<f:format.html parseFuncTSPath="lib.parseFunc_RTE"><f:link.page class="download" pageUid="fileadmin/redaktion/download/papers/{paper.download}" {paper.author}">PDF</f:link.page></f:format.html>

just wraps it into p.bodytext.

Do I have to use a different syntax to apply f:format.html TO f:link.page - or is there a better way to do it (via a fluid or vhs viewhelper)?

4

6 回答 6

2

实际上自定义 VH 是实现这一目标的最快方法,即基于此 VH,您需要将sizeparam 替换为文件路径,然后使用filesizePHP 的 ie 函数获取以字节为单位的大小。

于 2014-03-17T16:13:33.627 回答
2

这是我的VH:

https://gist.github.com/ursbraem/9645542

我稍微简化了原始文件,输出文件大小的“KiB”对我来说太技术性了。

于 2014-03-19T16:33:30.180 回答
1

当我使用流体内容时,我也安装了 vhs 扩展,然后只使用:

<f:format.bytes decimals="1">{v:media.size(path: '{file}')}</f:format.bytes>

这会输出清晰可读的大小,例如“28.2 MB”。

于 2016-05-12T11:39:03.827 回答
1

如果您使用 VHS,您可以考虑https://fluidtypo3.org/viewhelpers/vhs/master/Media/SizeViewHelper.html(与 结合使用f:format.bytes)。

于 2016-09-03T00:49:01.657 回答
0

在较新的 TYPO3 版本中,您可以使用originalResource.sizeFileReference 对象的属性。

{file.originalResource.size -> f:format.bytes()}

或者在你的情况下:

{paper.download.originalResource.size -> f:format.bytes()}
于 2019-03-05T13:23:31.713 回答
0

TYPO3 10

I needed a file size output for a DCE module in TYPO3 10, this is what I came up with, using VHS:

<f:format.bytes><v:media.size><v:format.trim characters="/"><f:uri.typolink parameter="{item.link}" /></v:format.trim></v:media.size></f:format.bytes>

Explained:

  • f:uri.typolink generates the full path I need for v:media.size
  • v:media.size requires the path without a leading slash, v:format.trim removes this character.
  • f:format.bytes displays the output from v:media.size in KB or MB.
于 2021-03-10T13:11:14.227 回答