Problem/Motivation
It seems Youtube videos don't use a template and instead rely on the $element[$delta] in src/Plugin/Field/FieldFormatter/AbleplayerRemoteVideoFormatter.php around line 120. This makes output customization difficult, without modifying the source code. For example if one wanted to add a special attribute to the video tag when Youtube was being used.
Steps to reproduce
- Require the module via composer per instructions.
- Delete its "templates" folder entirely.
- Enabled the module per instructions.
- Enable display for remote video per instructions.
Even with "templates" directory removed entirely, AbleplayerRemoteVideoFormatter.php will format the markup for Youtube.
Proposed resolution
Please provide a template and theme reference for a twig file instead of:
'#tag' => 'video',
'#attributes' => [...
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork ableplayer-3548775
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jim_b commentedComment #3
themusician commentedThank you for the idea.
It looks like AbleplayerRemoteVideoFormatter.php declares a field formatter, ableplayer_remote_video that we never used.
If we make that file and name it ableplayer-remote-video.html.twig and place it in /templates/ perhaps something like this would work.
Back in the AbleplayerRemoteVideoFormatter.php file we would need to remove
and
from both the YouTube and Vimeo provider checks.
Maybe that would work.
Comment #5
themusician commentedHi jim_b,
Carly and I have this working on the following branch, https://git.drupalcode.org/project/ableplayer/-/tree/3548775-provide-a-y.... I inadvertently messed up the fork process so it a standard branch off of the project.
The new twig template ends up looking like this:
We are testing internally, but if you or others are able to give this a test as well by pulling the branch, that would be much appreciated.
Comment #7
themusician commentedMerged into the dev branch. Please reopen if any edge cases are discovered.