Closed (fixed)
Project:
Video.js (HTML5 Video Player)
Version:
10.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Aug 2026 at 14:09 UTC
Updated:
8 Sep 2026 at 10:15 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
grevil commentedMight be once again an issue with the "default" skin. See #3618095: [10.x] Fix "videojs_player_remote" formatter not properly displaying vimeo and youtube videos.
Comment #3
grevil commentedComment #4
anybodyI think we should see this also as alpha blocker.
Comment #5
luwes commentedai;dr
Hey,
The issue is that the media-poster component isn't needed in the twig template, it's only needed in an ejected skin.
The best performance will be to use a plain img tag there with a `slot="poster"` attribute so it projects it in the skin.
More info below by AI.
---
I think I found it, and it isn't the skin — the poster image just never reaches
the skin's poster slot.
Both components wrap the poster in a `` of their own:
```twig
{% block poster_content %}
{{ poster }}
{% endblock %}
```
But the skins already carry one. From `@videojs/html` 10.0.0-beta.31,
`src/define/video/skin.ts` (and `minimal-skin.ts`, which is identical here):
```html
```
And the `PosterElement` docblock states the contract outright:
> `` — sets `src` on a poster image it does not own. […] Renders
`.
` of yours replaces the one the skin
> no image of its own, so include one: `
> **Inside a skin, an `
> carries.**
(Both quotes are verifiable from the CDN: `cdn/video.dev.js` and the
`sourcesContent` of `cdn/poster-element-BA7p_OJL.js.map`.)
Our wrapper has no `slot` attribute, so it is assigned to the skin's **default**
slot, landing beside the media element instead of inside the skin's
``. That accounts for both symptoms:
- **"doesn't fit the player"** — the positioning lives in the skin's shadow CSS
` paints during
as `.media-default-skin media-poster { position: absolute; inset: 0; … }` and
`.media-default-skin media-poster ::slotted(img) { position: absolute; inset: 0;
object-fit: … }`. A descendant selector inside a shadow root cannot match a
light DOM node assigned to a slot — only `::slotted()` reaches it — so our
wrapper gets none of that and the image renders at natural size, in flow.
- **"appears for one second and disappears"** — the `
parsing, then `media-poster` upgrades and applies its own visibility state
(`PosterCore.getState()` returns `visible: !media.started`, written out by
`applyStateDataAttrs`). We now have two PosterElements bound to the same
player state, and the one the skin's CSS actually styles is not ours. I am
fairly confident of the mechanism but have not stepped through it line by
line — the slotting problem above is the part I have verified.
## Fix (patch attached)
1. Drop the `` wrapper from `video-player.twig` and
`video-player-remote.twig`; print the poster straight into the skin.
2. `VideoJsVideoPlayerFormatterTrait::getPoster()`: add `slot="poster"` and
`decoding="async"` (matching the placeholder the skin ships) to the image
render array.
I put the attribute in `getPoster()` rather than the shared
`getImageFromSettings()` deliberately — the latter also builds the
click-through thumbnail for `videojs_trigger_link`, which must not be slotted.
Resulting markup:
```html

src="https://stream.mux.com/…m3u8">
```
Two side notes:
- The wrapper is currently emitted whenever `block('poster_content')` is not
` is plain markup, so the preload scanner starts the poster
empty, and a whitespace-only Twig block is not empty — so an empty
`` is rendered even when the poster setting is
"Disabled". Removing the wrapper takes care of that too.
- A slotted `
request during HTML parsing rather than after the ES modules load and upgrade
the custom elements. Nice win for LCP on poster-led pages.
The `poster_content` slot still works, but an override now has to carry
`.
`slot="poster"` itself; I documented that in both Twig docblocks. If you would
rather the component guarantee it, the alternative is keeping a wrapper and
putting `slot="poster"` on it — that works, but ships a second ``
where upstream expects just an `
Tested on Drupal 11.4.5 / PHP 8.4 against 10.x at 8ead389, CDN library, both
`default` and `minimal` skins. Happy to turn this into an MR if you create an
issue fork.
Comment #6
thomas.frobieterThanks a lot, @luwes! Great to have a library developer here.
So let's get this ready..
Comment #8
thomas.frobieterComment #9
grevil commentedAll green, except the phpunit test, but that is still unrelated and should be fixed in a follow-up issue. LGTM!
Comment #11
grevil commentedThanks all!