<media-poster-image>
Poster images give your viewers an idea of the contents of the video you’re displaying before they view the video. These images can be something as simple as a specific frame from your video, or, a completely custom designed composition of your choice.
The <media-poster-image>
component will show your poster image in place of your media before the media has been played. You can also optionally show a secondary placeholder image before the poster has loaded. This is generally useful to prevent layout shifts.
For example, you can show a blurhash that mirrors the colors that will appear within your poster image while your actual poster image loads.
You can either use the <media-poster-image>
component as a static image on its own, or, add the slot="poster"
attribute to associate it with the underlying video element for click-to-play.
With src
Section titled With srcWith placeholdersrc
and src
Section titled With placeholdersrc and srcHiding the poster image on play
Section titled Hiding the poster image on playWhen your media begins to play back, media-controller
will be assigned the mediahasplayed
attribute. Media Chrome default styling will ensure that any media-poster-image
elements that are a child of media-controller
are hidden when this attribute is present.
Reference
Section titled ReferenceAttributes
Section titled AttributesName | Type | Description |
---|---|---|
placeholdersrc | string | Placeholder image source URL, often a blurhash data URL. |
src | string | Poster image source URL. |
CSS Variables
Section titled CSS VariablesName | Default | Description |
---|---|---|
--media-poster-image-display | inline-block | display property of poster image. |
--media-poster-image-background-position | var(--media-object-position, center) | background-position of poster image. |
--media-poster-image-background-size | var(--media-object-fit, contain) | background-size of poster image. |
--media-object-fit | contain | object-fit of poster image. |
--media-object-position | center | object-position of poster image. |