Video files using the FileVideoFormatter have a fixed dimension

Created on 22 October 2021, over 2 years ago
Updated 18 March 2024, 3 months ago

Problem/Motivation

Media video files (but not remote video files) use the FileVideoFormatter.

This formatter's settings form includes options to set width and height attributes on the <video> element.
These fields are correctly set to be numeric- however they are both marked required. This means any displayed video will have these same fixed dimensions, regardless of an individual video's actual dimensions.

Although the video width can still be controlled with css, these fixed attributes can cause problems like extra white space between the video and the controls when the set size is a different aspect ratio than the video.

FileVideoFormatter was added in File field formatters for rich media display with Fixed

Steps to reproduce

  1. Visit the Manage Display page for a Video Media type. admin/structure/media/manage/video/display
  2. Edit the Format settings by clicking the cog.
  3. Width and Height are both required.

Proposed resolution

Remove the #required attribute from both width and height in the settingsForm
core/modules/file/src/Plugin/Field/FieldFormatter/FileVideoFormatter.php

This will allow a browser to display a video at its natural aspect ratio.

  • If neither dimension is provided, the video will be rendered in its original aspect ratio.
  • If only width or height is provided, the video will use that dimension.
  • If both width and height are provided, the video will be rendered with those dimensions.

Remaining tasks

User interface changes

Allows users to leave the width and height blank for a video

Before

After

API changes

NA

Data model changes

NA

Release notes snippet

NA

🐛 Bug report
Status

Fixed

Version

10.3

Component
File module 

Last updated 3 days ago

Created by

🇺🇸United States zrpnr UTC-7

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024