v:iterator.random | 随机图像缓存问题
Random image with v:iterator.random | cache issue
我尝试使用 VHS(版本 2.4.0)RandomViewHelper 输出 1 个随机图像 v:iterator.random
。
这是我的代码:
{namespace flux=FluidTYPO3\Flux\ViewHelpers}
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<f:layout name="Content" />
<f:section name="Configuration">
<flux:form id="random-image" label="Random Image" options="{icon: 'Icons/Content/Example.gif', group: 'Joya'}">
<flux:field.input name="classname" label="Classname" />
</flux:form>
<flux:form.section name="images" label="Images">
<flux:form.object name="image" label="Image">
<flux:field.file name="imagesrc" label="Image" allowed="png,jpg" maxItems="1" size="1" />
</flux:form.object>
</flux:form.section>
</f:section>
<f:section name="Preview">
Random Image
</f:section>
<f:section name="Main">
<div class="random-image">
<v:iterator.random as="img" subject="{images}">
{img.image.imagesrc}
</v:iterator.random>
</div>
</f:section>
我添加了 3 张图像进行测试,但它始终输出相同的图像。
编辑: random 的输出被缓存。所以它在清除缓存后输出另一个图像。
我可以只为这行代码禁用缓存吗?
https://fluidtypo3.org/viewhelpers/vhs/2.4.0/Iterator/RandomViewHelper.html
另一种方法是通过 ajax 调用真正加载图像,这样您可以缓存页面,但不能缓存随机图像。
解决方案是使用 VHS ViewHelper v:render.uncache
并使用不应缓存的部分创建部分。它不是最佳解决方案,因为您需要一个额外的文件。但是现在我唯一能想到的其他方法就是使用一些 Typoscript,这也是我想避免的。
我尝试使用 VHS(版本 2.4.0)RandomViewHelper 输出 1 个随机图像 v:iterator.random
。
这是我的代码:
{namespace flux=FluidTYPO3\Flux\ViewHelpers}
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<f:layout name="Content" />
<f:section name="Configuration">
<flux:form id="random-image" label="Random Image" options="{icon: 'Icons/Content/Example.gif', group: 'Joya'}">
<flux:field.input name="classname" label="Classname" />
</flux:form>
<flux:form.section name="images" label="Images">
<flux:form.object name="image" label="Image">
<flux:field.file name="imagesrc" label="Image" allowed="png,jpg" maxItems="1" size="1" />
</flux:form.object>
</flux:form.section>
</f:section>
<f:section name="Preview">
Random Image
</f:section>
<f:section name="Main">
<div class="random-image">
<v:iterator.random as="img" subject="{images}">
{img.image.imagesrc}
</v:iterator.random>
</div>
</f:section>
我添加了 3 张图像进行测试,但它始终输出相同的图像。 编辑: random 的输出被缓存。所以它在清除缓存后输出另一个图像。
我可以只为这行代码禁用缓存吗?
https://fluidtypo3.org/viewhelpers/vhs/2.4.0/Iterator/RandomViewHelper.html
另一种方法是通过 ajax 调用真正加载图像,这样您可以缓存页面,但不能缓存随机图像。
解决方案是使用 VHS ViewHelper v:render.uncache
并使用不应缓存的部分创建部分。它不是最佳解决方案,因为您需要一个额外的文件。但是现在我唯一能想到的其他方法就是使用一些 Typoscript,这也是我想避免的。