@wordpress/block-library
Version:
Block library for the WordPress editor.
84 lines (63 loc) • 4.92 kB
Markdown
# Playlist
<!-- START TOKEN(Autogenerated block API docs) -->
Embed a simple playlist.
- **Name:** `core/playlist`
- **Category:** [media](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-media/)
- **API Version:** [3](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/)
- **Block Type:** [Hybrid](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/) (static save + server enhancements)
- **Keywords:** `music`, `sound`
## Block Relationships
**[Allowed](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#allowed-blocks) inner blocks:**
- [`core/playlist-track`](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-media/core-block-playlist-track/)
## Attributes
_Defined via the [`attributes`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/) property in block.json._
| Attribute | [Type](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#type-validation) | [Default](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#default-value) | Description |
|-----------|------|---------|-------------|
| `type` | `string` | `"audio"` | — |
| `order` | `string` | `"asc"` | — |
| `showTracklist` | `boolean` | `true` | — |
| `showImages` | `boolean` | `true` | — |
| `showPlayButtonArtwork` | `boolean` | `false` | — |
| `showArtists` | `boolean` | `true` | — |
| `showNumbers` | `boolean` | `true` | — |
| `showTrackLength` | `boolean` | `true` | — |
| `waveformStyle` | `string` | `"bars"` | [Enum](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#enum-validation): `bars`, `mirror`, `line`, `blocks`, `dots`, `seekbar` |
| `waveformColor` | `string` | — | — |
| `waveformGradient` | `string` | — | — |
| `waveformBackgroundColor` | `string` | — | — |
| `waveformBackgroundGradient` | `string` | — | — |
| `caption` | `string` | — | — |
## Supports
_Defined via the [`supports`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/) property in block.json._
- [`anchor`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#anchor): `true`
- [`align`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#align): `true`
- [`color`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color):
- [`gradients`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-gradients): `true`
- [`link`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-link): `true`
- [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity): `true`
- [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
- `margin`: `true`
- `padding`: `true`
- [`typography`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography):
- [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
## Context
_Defined via the [`usesContext` and `providesContext`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-context/) properties in block.json._
**Provides context:**
- `showArtists` → attribute `showArtists`
- `showImages` → attribute `showImages`
## Block Markup
This is a [**hybrid block**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/). It saves static markup that the server may enhance during rendering.
```html
<!-- wp:core/playlist {"caption":"Sample playlist"} -->
<figure class="wp-block-playlist">
<ol class="wp-block-playlist__tracklist wp-block-playlist__tracklist-show-numbers">
<!-- wp:core/playlist-track {"id":123,"src":"https://example.com/audio.mp3","album":"Example album","artist":"Example creator","image":"https://example.com/track-image.jpg","imageAlt":"Track image","length":"3:21","title":"Sample track"} /-->
</ol>
<figcaption class="wp-element-caption">Sample playlist</figcaption>
</figure>
<!-- /wp:core/playlist -->
```
## Source
- [block.json](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/playlist/block.json) ([reference](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/))
- [Source directory](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/playlist/) — browse `edit.js`, `save.js`, `index.php`, and more.
<!-- END TOKEN(Autogenerated block API docs) -->