Reputation: 740
In the context of EXT:blog
(which may or may not be relevant) on TYPO3 8.7 I added a YouTube video under Resources > Files > Media > Add media by URL. This results in a reference to a .youtube
file.
Within List\Post.html
, a Fluid template which overrides EXT:blog
's Post.html
, I get access to the post.media
array. post.media
contains a FileReference
. When rendering that using <f:image src="thatreference.uid" treatIdAsReference="1" .../>
I do get the video's thumbnail.
How do I determine whether a post.media
entry refers to a YouTube video and how do I render that video instead of the thumbnail image? I could not find any useful properties on that FileReference
(such as media type or YouTube video ID) yet. Do I need to go another route?
Upvotes: 0
Views: 2176
Reputation: 740
Media, including images and videos, can be output using the f:media ViewHelper:
<f:media file="{thatreference}" width="400" height="375"/>
To determine the resources media type use {thatreference.originalResource.originalFile.type}
. A value of 4 stands for video, 2 stands for images:
<f:if condition="{thatreference.originalResource.originalFile.type} == 4">…</f:if>
The original YouTube URL can be read from {thatreference.originalResource.publicUrl}
and various other properties such as preview dimensions (useful for calculating aspect ratio) from {thatreference.originalResource.properties}
.
Upvotes: 1
Reputation: 3207
You can do like this. For more details f:media.
You can get your file path like this {thatreference.originalResource.publicUrl}
<f:media file="{your file path}" width="400" height="375" additionalConfig="{loop: '1', autoplay: '1'}" />
Upvotes: 1
Reputation: 7939
Just use <f:media />
which outputs all media types including youtube videos
Upvotes: 1