Problem/Motivation
The Video.js formatters expose Width and Height settings that output fixed pixel width/height attributes on the media element. That conflicts with the module’s responsive CSS (width: 100%, aspect-ratio) and is an unusual way to size video players today. The defaults are already “Auto”, so the settings add UI complexity with little benefit.
Steps to reproduce
Remove width and height from formatter settings, config schema, SDC props, and Twig templates. Add an update hook to strip those keys from existing entity view display configs. Sites that need fixed sizing can handle it with CSS on .video-player or the surrounding layout.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork videojs-3619630
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 #3
grevil commentedAll done, please review!
Comment #4
thomas.frobieterWidth and height attributes are still required on the video element to prevent Cumulative Layout Shift (CLS).
But I agree, we don't need this in the formatter settings. Its just confusing.
So lets stick with the height and with properties on the video-player SDCs, fix the docs:
I've tested a bit in order to reduce CLS and FOUC.
At the moment, we only set the height and width of the video HTML element (and on the video-player-rmote SDCs mediaComponent). I think we should set them for the video player element too. So additonaly:
{# Always set width and height to prevent CLS #}
{% set attributes = attributes.setAttribute('width', width|default('640')) %}
{% set attributes = attributes.setAttribute('height', height|default('360')) %}
{# Only required on the video-player SDC, can be remove on video-player-remote because we dont print the iframe element #}
{% set mediaAttributes = mediaAttributes.setAttribute('width', width|default('640')) %}
{% set mediaAttributes = mediaAttributes.setAttribute('height', height|default('360')) %}
We should also add this to the poster image (turn off JS to see the problem):
The Video.js player doesn't care about this class, grabs the poster image and everything works fine.
We also should add some CSS to reduce FOUC:
Comment #5
thomas.frobieterDone
Comment #6
grevil commentedGreat stuff! LGTM!
Comment #8
grevil commented