Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#65835 new enhancement

Excerpts: Extract content from Playlist block tracks

Reported by: huzaifaalmesbah Owned by:
Priority: normal Milestone: Future Release
Component: Editor Version: 7.1
Severity: normal Keywords:
Cc: Focuses:

Description

The Playlist block contains meaningful content for each track, including Title, Artist, and Album. However, when WordPress automatically generates an excerpt, this content does not appear to be considered.

For example, a Playlist track can contain:

Artist: Unknown artist
Album: Unknown album
Title: sample-3s

The Title, Artist, and Album fields provide meaningful textual content that could be used when generating an automatic excerpt.

Steps to reproduce

  1. Create a new post.
  2. Add a Playlist block.
  3. Add an audio track.
  4. Set the track Title, Artist, and Album.
  5. Publish the post without adding a manual excerpt.
  6. Retrieve the post through the REST API:
/wp-json/wp/v2/posts/<post-id>
  1. Check the excerpt.rendered value.

Actual result

The Playlist track content is not included in the automatically generated excerpt.

For example:

"excerpt": {
    "rendered": "",
    "protected": false
}

Expected result

The automatically generated excerpt should include meaningful textual content from the Playlist tracks.

For example:

sample-3s

Or, when the metadata is available:

sample-3s — Artist Name — Album Name

Proposed solution

Consider extracting the available Title, Artist, and Album metadata from Playlist tracks when generating automatic excerpts.

The Title could be prioritized, while Artist and Album could be included when available. Default values such as Unknown artist and Unknown album could be ignored.

This would be similar to how WordPress considers meaningful nested content from other blocks when generating automatic excerpts.

Change History (2)

#1 @abcd95
4 weeks ago

Thanks for the detailed report!

I looked into how excerpt_remove_blocks() works. It uses an allowlist of blocks that can contribute rendered HTML to auto-excerpts. core/playlist and core/playlist-track aren't included, so their content gets skipped. Since the useful text (title, artist, and album) lives in block attributes rather than inner text blocks, it never makes it into the excerpt.

I see two possible approaches:

We can maybe either add core/playlist to excerpt_allowed_wrapper_blocks, this would allow the playlist to be rendered normally for the excerpt, OR handle playlists explicitly. We could add a dedicated excerpt handler for core/playlist and extract the track attributes directly. We can include the track title and optionally the artist/album when they have meaningful values, while skipping defaults like "Unknown artist" and "Unknown album".

I prefer Option 2. It's more explicit, avoids depending on the block's rendered HTML, and gives us better control over what appears in excerpts. It also matches how the playlist block already builds its accessible labels.

Important to note that this should also have visibility in Gutenberg Ecosystem

#2 @wildworks
4 weeks ago

  • Milestone Awaiting ReviewFuture Release
  • Type defect (bug)enhancement

Thanks for the suggestion. This looks like a feature enhancement rather than a bug to me. Let's consider implementing it in a future release.

Note: See TracTickets for help on using tickets.