typo3 flux: Obtain File reference object to render video tag via f:media

raw

README.rst

<f:media file="{file}"> wants a file object, one of:

  • TYPO3CMSCoreResourceFile
  • TYPO3CMSCoreResourceFileReference
  • TYPO3CMSExtbaseDomainModelFileReference

(see https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Fal/UsingFal/Frontend.html#the-imageviewhelper)

You cannot use <v:content.resources.fal>, because you'll get an exception then:

The argument "file" was registered with type "object", but is of type "array" in view helper "TYPO3CMSFluidViewHelpersMediaViewHelper".

Solution: Use v:resource.record.fal with the asObjects attribute (vhs 6.0.5)

Search keywords:

  • typo3 "flux" "TYPO3CMSCoreResourceFile" object
  • typo3 f:media video flux
  • typo3 fluid vhs f:media file example
raw

Video.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
  xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
  xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
  xmlns:flux="http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers">
 
<f:layout name="ContentElement" />
 
<f:section name="Configuration">
  <flux:form id="Video">
    <flux:field.inline.fal name="settings.video"
      required="1" maxItems="1" minItems="0" collapseAll="1"
      allowedExtensions="mp4" />
  </flux:form>
</f:section>
 
  <f:section name="Preview">
    {v:content.resources.fal(field: 'settings.video', record: record) -> v:iterator.first() -> v:variable.set(name: 'video')}
    <f:if condition="{video}">
      Video: {video.identifier}
    </f:if>
  </f:section>
 
  <f:section name="Main">
    {v:resource.record.fal(table: 'tt_content', field: 'settings.video', record: record, asObjects: 1) -> v:iterator.first() -> v:variable.set(name: 'video')}
    <f:if condition="{video}">
      <f:media file="{video}" additionalAttributes="{controls: 'controls'}"/>
    </f:if>
  </f:section>
</html>
 
Christian Weiske Christian Weiske
owner

History