letterncms / spotify
A Spotify block: a track, album, playlist, artist, podcast episode or show with Spotify’s player, sized to fit what it plays.
Requires
- php: ^8.4
- letterncms/cms: >=0.36 <1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Adds a Spotify block: a song, album, playlist, artist, podcast episode or show with Spotify's own player. Paste its link from Spotify's Share menu, as open.spotify.com/… or a spotify: URI. One thing to play gets the compact player and a list gets the tall one, or choose a size.
The site asks Spotify about each link once, not the visitor: its title, which screen readers read when the block has none, and whether it can be shown. Something private or gone shows nothing on the page, and the block says why in the editor, as it does for a short spotify.link link or a link to a library.
With Load on Click, the page shows a card in the player's place: the cover, on the colour it is mostly made of, the title and a link to it on Spotify. Spotify's player loads in its place, at the same height, when a visitor presses it. The site copies the cover into public/_cms/spotify/ when it asks Spotify about the link, so until a visitor presses the card nothing on the page contacts Spotify. It is off by default, since Spotify's player can't start playing by itself and visitors would press twice. The editor always shows the card: it runs no scripts, so Spotify's player could only show half of itself there.
Install
From Plugins → Store in the admin, or:
composer require letterncms/spotify
Settings
The plugin has no settings of its own. The block has these:
| Setting | What it does |
|---|---|
Spotify Link (url) |
The link or URI. |
Title for Screen Readers (title) |
Read out for the player. Empty: its title on Spotify. |
Size (size) |
auto (152 pixels for a song or an episode, 352 for the rest), slim (80, one row), compact (152) or tall (352). |
Colors (theme) |
auto, Spotify's colors from the artwork, or dark. Spotify's player has no light version. |
Load on Click (load_on_click) |
Off by default. On, a card first and the player on a click. |
In Block Markdown:
::: spotify/player {"props":{"url":"https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M","theme":"dark"}}
:::
With the site's content security policy on, the player's frame from open.spotify.com is allowed.
Abilities
None of its own. Agents add the block like any other, through the blocks/* and entries/* abilities; blocks/types lists it with an example.
Hooks
It adds the player's host to the core's site.policy filter, and adds no hooks of its own.
This repository is published from letterncms/plugins-public. Open issues and pull requests there.