随机图像与v:iterator.Random|缓存问题



我尝试使用VHS(2.4.0版本)RandomViewHelper v:iterator.random输出1个随机图像。

这是我的代码:

{namespace flux=FluidTYPO3FluxViewHelpers}
{namespace v=FluidTYPO3VhsViewHelpers}
    <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个图像进行测试,但它总是输出相同的图像。编辑:随机输出被缓存。因此,它在清除缓存后输出另一个图像。

我可以仅为这行代码禁用缓存吗?

https://fluidtypo3.org/viewhelpers/vhs/2.4.0/Iterator/RandomViewHelper.html

解决方案是使用VHS ViewHelper v:render.uncache并用不应缓存的部分创建一个分部。这不是最好的解决方案,因为您需要一个额外的文件。但现在我唯一能想到的另一种方法是使用一些类型文字,这也是我想避免的。

另一种方法是通过ajax调用加载图像,这样可以缓存页面,但不能缓存随机图像。

最新更新