Reputation: 83
I want to be able to add a fallback video file in the Backend. So the Backend User can add the same video in a different file format, for the browsers that dont support the primary file format. Example: the primary video file format ist .webm and the secondary file format is a .mp4.
I've created the TCA Overrider for sys_file_reference.php
$temporaryColumn = array(
'tx_framework_video_fallback' => [
'label' => 'LLL:EXT:gizmo_framework/Resources/Private/Language/locallang_be.xlf:Pages.videoOptionFallbackVideo.Title',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('tx_framework_video_fallback', [
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:gizmo_framework/Resources/Private/Language/locallang_be.xlf:Pages.videoOptionPoster.addPoster'
],
],
//Filter for File Types ex. images
'mp4,gif,mov')
],
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'sys_file_reference',
$temporaryColumn
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'sys_file_reference',
'videoOverlayPalette',
'--linebreak--,tx_framework_video_fallback',
'after:autoplay'
);
And here is the ext_table.sql
CREATE TABLE `sys_file_reference` (
'tx_framework_video_fallback' int(11) unsigned DEFAULT '0' NOT NULL,
);
And I load the video via the content element typoscript
tt_content.textmedia =< lib.contentElement
tt_content.textmedia {
templateName = Textmedia
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = assets
}
20 = TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor
20 {
maxGalleryWidth = {$styles.content.textmedia.maxW}
maxGalleryWidthInText = {$styles.content.textmedia.maxWInText}
columnSpacing = {$styles.content.textmedia.columnSpacing}
borderWidth = {$styles.content.textmedia.borderWidth}
borderPadding = {$styles.content.textmedia.borderPadding}
}
}
}
So far so good I can add a video in the content element in the backend and it will display in the Front End.
But I'm not able to load the video that I have linked to the sys_file_reference. It is being safed correctly and added to the sys_file_reference table.
I've tried to load the fallback video within the dataProcessor of the content element typoscript
tt_content.textmedia =< lib.contentElement
tt_content.textmedia {
templateName = Textmedia
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = assets
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10{
references.table = sys_file_reference
references.fieldName = tx_framework_video_fallback
as = fallbackMediaReference
}
}
}
20 = TYPO3\CMS\Frontend\DataProcessing\GalleryProcessor
20 {
maxGalleryWidth = {$styles.content.textmedia.maxW}
maxGalleryWidthInText = {$styles.content.textmedia.maxWInText}
columnSpacing = {$styles.content.textmedia.columnSpacing}
borderWidth = {$styles.content.textmedia.borderWidth}
borderPadding = {$styles.content.textmedia.borderPadding}
}
}
}
I've also tried to use the DatabaseQueryProcessor, but I've never got the file object of the video.
How do I have to setup the dataProcessing to load the secondary file which is linked to the sys_file_reference of the primary file.
Thanks for your help!
Upvotes: 0
Views: 1822
Reputation: 83
Here is my answer using the FLUIDTEMPLATE f:cObject. Thanks for the hint Jo Hasenau!
I hope I can help someone with the same problem.
Fluidtemplate.html:
<f:cObject typoscriptObjectPath="lib.fallbackMedia" data="{file}"/>
setup.typoscript
lib.fallbackMedia = FILES
lib.fallbackMedia {
//references the table, field and which uid it should get
references{
table = sys_file_reference
fieldName = tx_framework_video_fallback
uid.data = uid
}
//renders the references as an IMG Resource
renderObj = COA
renderObj {
10 = IMG_RESOURCE
10 {
file.import.dataWrap = {file:current:storage}:{file:current:identifier}
stdWrap.dataWrap = <source src="|" type="{file:current:mime_type}">
}
}
}
For more information on the FILES cObject: https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Files/Index.html
In the fluid template you are now able to build the HTML Video Tag with multiple sources.
Upvotes: 0
Reputation: 2684
Since there is currently no additional dataProcessing
available within the Files processor, you will either have to go for your own custom dataProcessor or create a workaround.
The workaround could indeed be based on the DatabaseQueryProcessor
, since that will give you the additional data processor that's still missing in the FilesProcessor. On the other hand you could go for an additional FLUIDTEMPLATE
setup to be used while rendering the file list provided by your FilesProcessor.
If you prefer the DatabaseQueryProcessor
you will have to use a join query to get the necessary files, which might be a bit more complicated.
https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Select.html
If you go for the additional FLUIDTEMPLATE
you can just add that with the f:cObject
view helper while rendering the primary file list and hand over the reference record as data
.
https://docs.typo3.org/other/typo3/view-helper-reference/9.5/en-us/typo3/fluid/latest/CObject.html
If you want that problem to be solved within the FilesProcessor itself, you might want to support this issue, which has been started during the last TYPO3 initiative week https://forge.typo3.org/issues/88627
Upvotes: 1