ReferenceDisplay
media-poster
Poster image component that displays a thumbnail until video playback starts
Import
Anatomy
Behavior
The poster shows before playback starts. Once the user plays or seeks, it hides; pausing does not bring it back. Loading a new source shows it again.
The <img> child is optional. Leave it out and <media-poster> draws one of its own in its shadow DOM.
You can set the poster URL on the player. This is useful when you want to change the poster from inside a skin, or keep all your media metadata in one place:
Supply your own image
The component fills in a source only when you leave one out. srcset, sizes, loading, <picture>, and framework image components all stay available.
<media-poster> draws a fallback image in its shadow DOM and fills in its src. Put an <img> inside it and the element uses yours instead, filling in its src the same way:
Give that image a src, a srcset, or <source> candidates and it is yours; the component leaves it alone:
Inside a skin, slot your image instead. The skin carries a plain one that yours replaces:
A skin can only style an <img> you slot directly. Wrap one in a <picture> or a framework component and its sizing is yours.
Styling
The three load attributes track the image on screen, including one you supplied yourself.
The image the element draws is exposed as a part. An image you supply is an ordinary child, so style it as a descendant:
From inside a skin’s shadow root, an image slotted from outside needs ::slotted(img) as well.
Accessibility
Unlike the native <video poster> attribute, this component lets you describe the poster for screen readers.
The image is decorative by default (alt=""), since a URL says nothing about what the image shows. When the poster carries meaning, say so:
Whether a poster is informative or decorative is your judgment, per the WAI guidelines.
Examples
Basic Usage
API Reference
media-poster
<media-poster> — sets src on a poster image it does not own.
The image is a child, as in <picture>, but sourcing runs the other way around: <picture> treats the src on its
<img> as the fallback, while here an image with no source of its own is the one this element fills in. Give the
child a src, a srcset, or <source> candidates and it is yours, left alone.
Left empty, the element draws an image of its own in its shadow root. Supply one as a child to describe it or wrap
it: <media-poster><img alt="Keynote speaker"></media-poster>. Inside a skin, an <img slot="poster"> of yours
replaces the one the skin carries.