Skip to content

Conversation

@simonbyford
Copy link
Contributor

@simonbyford simonbyford commented Dec 23, 2025

What does this change?

Does two things:

  1. sets the aspect ratio of the container for looping videos in articles by passing in containerAspectRatio. This follows on from Set aspect ratio of containers to prevent CLS #15029
  2. adds support for full-width self-hosted videos. Looping videos in articles should display at full-width. Looping videos on fronts should continue to display in a fixed-size box with letterboxing (i.e. not full-width)

Why?

Editorial have requested it. There is a precedent because this is how images currently behave in articles.

Screenshots

Before After
Screenshot 2025-12-23 at 12 06 51 Screenshot 2025-12-23 at 12 00 12

@github-actions
Copy link

github-actions bot commented Dec 23, 2025

@simonbyford simonbyford changed the title Fix aspect ratio for looping videos in articles Support full-width looping videos in articles Dec 23, 2025
@simonbyford simonbyford marked this pull request as ready for review December 23, 2025 12:11
@github-actions
Copy link

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@simonbyford simonbyford added the run_chromatic Runs chromatic when label is applied label Dec 23, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Dec 23, 2025
@paperboyo
Copy link
Contributor

🎁🎄 Yay!

Just a useless naming thought: even though fronts were where the player was born, they are a special case (letter-boxed?), while the behaviour in articles after your PR is what’s normal and expected. Once we finally have different weightings (roles) there, it may not exactly be “full-width” either.

If it’s easier as is, I haven’t wrote this comment.

Merry Xmas!

@simonbyford
Copy link
Contributor Author

🎁🎄 Yay!

Just a useless naming thought: even though fronts were where the player was born, they are a special case (letter-boxed?), while the behaviour in articles after your PR is what’s normal and expected. Once we finally have different weightings (roles) there, it may not exactly be “full-width” either.

If it’s easier as is, I haven’t wrote this comment.

Merry Xmas!

Thanks @paperboyo! I like your suggestion and I've made the change here: 0f2b3b0

letterboxed is false in the default case, but true for fronts.

}
subtitleSize={subtitleSize}
enableHls={enableHls}
letterboxed={true}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why we're touching the Fronts card here? Is calculating the aspect ratio from the video itself not enough?

Another thought - what happened with the rumours that people were looking to add an aspect ratio attribute to media atoms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair question, I've bundled together 2 distinct changes in this PR which is causing confusion. It probably should have been 2 PRs.

The first change uses the aspect ratio of the video to calculate the size of the video container for the purposes of reducing CLS. It has no impact on whether or not the video displays letterboxes. It just follows on from this PR where it was missed: #15029

The second change introduces the concept of letterboxes which can be enabled or disabled. Since the default state is to disable letterboxes (see Mat's comment), we need to change the Fronts card to enable them again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought - what happened with the rumours that people were looking to add an aspect ratio attribute to media atoms?

If I understand you correctly, such a field exists now. But it's a string (e.g. "5:4") and we need a numerical value so I opted to use the dimensions instead.

Copy link
Contributor

@RikRootsGuardian RikRootsGuardian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to approve, following discussion.

@simonbyford simonbyford added the run_chromatic Runs chromatic when label is applied label Jan 6, 2026
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Jan 6, 2026
@simonbyford simonbyford merged commit aa960c0 into main Jan 6, 2026
28 checks passed
@simonbyford simonbyford deleted the fix-aspect-ratio branch January 6, 2026 14:52
@gu-prout
Copy link

gu-prout bot commented Jan 6, 2026

Seen on PROD (merged by @simonbyford 8 minutes and 42 seconds ago) Please check your changes!

subtitleSource?: string;
subtitleSize: SubtitleSize;
enableHls: boolean;
letterboxed?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does letterboxed mean? Is it where the video can appear with grey bars at its left and right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. I appreciate it isn't a standard or obvious term though and I'm open to changing it if you have any ideas? I originally went with fullWidth (to mean the opposite of letterboxed) but after some feedback I changed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault for choosing the term itself (and, in our case, more correct would be, even more obscure, pillarbox). But while I don’t care for the term much, I think the reasoning behind my earlier comment still stands? (whatever works, ofc, though!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning is solid. The name is obscure but perhaps just a comment explaining it would clear things up?

Comment on lines +64 to +66
max-height: 100vh;
max-height: 100svh;
max-width: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these three lines of CSS not useful for video on articles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requirement was that looping videos should take up the full width of an article, regardless of their aspect ratio. If you introduce a max-height then some very tall videos cannot take up the full width. For example:

Image

Source: https://viewer.code.dev-gutools.co.uk/preview/music/2025/dec/17/simon-looping-video-test

In reality this is an edge case and will probably never happen but that's what motivated me to make this change.

max-width: 100% should be fine though and can be moved out of the conditional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants