Hauer-Heinrich / hh_slider

TYPO3 extension. Adds tiny-slider to TYPO3.
MIT License
1 stars 2 forks source link

add new content-type video / add & customize file formats for content-type image #26

Open medarob opened 3 years ago

medarob commented 3 years ago

Hi,

via the content-type images it's possible to add individual images to a slider. If an editor wants to create a video slider, the content type folder has to be used. The folder has then all video files included.

grafik

There are cases where video files exists in different folders across the filelist, so it's not possible to create a videoslider from videos in different folders.

Would it be possible to create a new content type video with support for mp4, webm, mpd and m3u8? The last two formats are the streaming formats MPEG Dash and HLS and the extensions .mpd and .m3u8 are the playlist files.

Or as an alternative, would it be possible to add those formats to the content-type image and rename that content-type to media? Not sure if that is already possible, that the extension could be configured to add or remove file formats in the image content-type?

Teisi commented 3 years ago

Custom fields:

you can change and add your own fields to fit your needs, see: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ExtendingTca/Examples/Index.html#extending-examples-ttcontent

example:

// your_ext/Configuration/TCA/Overrides/tt_content.php
$test = [
    'tx_hhslider_folder_test' => [
        'exclude' => 1,
        'label' => 'LLL:EXT:hh_slider/Resources/Private/Language/locallang_db.xlf:tt_content.tx_hhslider_folder',
        'displayCond' => 'FIELD:tx_hhslider_content_type:=:12',
        'config' => [
            'type' => 'group',
            'internal_type' => 'folder',
            'size' => 1,
            'maxitems' => 1,
            'minitems' => 1,
            'show_thumbs' => 0,
            'eval' => 'trim'
        ],
    ],
];

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $test);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
    'tt_content',
    'tx_hhslider_folder_test',
    'hhslider_hh_slider',
    'after:tx_hhslider_content_type'
);
// Page TypoScript
TCEFORM {
    tt_content {
        tx_hhslider_content_type.addItems.12 = test
    }
}
// and / or extend TypoScript "tt_content.hhslider_hh_slider"
// pls use 100 and above for custom ones!
tt_content.hhslider_hh_slider {
    dataProcessing {
        100 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
        100 {
            if.isTrue.field = tx_hhslider_folder_test
            folders.field = tx_hhslider_folder_test
            sorting.field = tx_hhslider_sorting
            sorting.direction.field = tx_hhslider_sorting_direction
            as = folderFilesTest
        }
    }
}
// ext_tables.sql
CREATE TABLE tt_content (
    tx_hhslider_folder varchar(255) DEFAULT '' NOT NULL,
);

Image field with videos

That is a good hint, thank you. We'll have to look into that at some point. But until then, feel free to expand the field, for example:

// your_ext/Configuration/TCA/Overrides/tt_content.php
$GLOBALS['TCA']['tt_content']['types']['hhslider_hh_slider']['columnsOverrides'] = array(
    'assets' => [
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'assets',
            [],
            'jpg, jpeg, png, svg, webm, webp, mp4, ogg, ogv'
        ),
    ],
);
medarob commented 2 years ago

Thank you for your explanations 🙂

I added additional file formats via a patch but I changed my approach to your suggestion.

I also tried to add another content-type option for Video files only but that did not work out. Then I had two fields with the same media files (assets) if I had selected the new option. Not sure what went wrong but I'm probably missing something.

For now, the additional file extensions at the first content-type option "Images" do work so that I can add video files to a slider. That's probably a good solution. You either have an Image only or Video only slider, maybe in rare use cases you have both images and videos in one sliders. Those 3 use cases can be accomplished with allowing video files at the first content_type. If you have an extra content-type for videos you can create an image only and video only slider but a mix of both is not possible I would say. For example if you have the order: image | video | image | image | video.

Not sure if there would be an advantage to have a separate option for video files only... 🤔

As an idea: Maybe it's possible to make the file extension list changeable via a Typoscript setting? But not sure if that is possible.