Problem/Motivation
The podcast episode carried two separate audio fields: field_audio, a local file upload, and field_audio_url, a link. An editor had to choose between them with nothing saying which one the page would render, and the two were bound to two separate components in the Canvas full template, one of which rendered empty on every episode.
Drupal already has a well understood pattern for exactly this: a single media reference field, where the editor picks the bundle from the media library, the way Video and Remote video already work.
Steps to reproduce
- Install a Varbase Starter site on Varbase 11.
- Apply the Varbase Podcasts Base recipe from
1.0.x-dev. - Go to
/node/add/podcast. The form offers two audio fields, Audio (a file upload) and Audio URL (a link), and nothing on the form says which one the episode page will render. - Fill in only Audio URL, save, and view the episode. The Canvas full template still renders the component bound to the file field, and it renders empty.
Proposed resolution
field_audiobecomes an entity reference tomedia, targeting theaudioandremote_audiobundles.field_audio_urlis removed, storage and instance.- The default form display uses the Media Library widget.
- The
fullview display renders the referenced media withentity_reference_entity_view, so each bundle renders through its own media display: a local file gives anaudio controlsplayer, a remote one gives the provider's embed, without the node display needing to know which bundle it got. - The Canvas
node.podcast.fullcontent template walks node to media to file for the local case, and drops the component that was bound to the removed link field. - Test content gains an audio media entity, and all twelve episodes reference it.
Dependency
The remote_audio bundle comes from Varbase Media Base, issue #3624670. This issue's field config depends on media.type.remote_audio, so #3624670 has to land first.
Verification
Done on a fresh Drupal CMS plus Varbase Starter install:
- The recipe applies cleanly to a freshly installed Varbase Starter site.
field_audioisentity_referencetomediawith target bundlesaudio,remote_audio, andfield_audio_urlis absent.- The test-content recipe applies and all 12 episodes resolve to a real audio media entity, with no dangling references.
- The local audio media entity renders
audio controlswith asourcepointing atvarbase-example-episode.wav, typeaudio/wav, through its own default display. - The Canvas template's media to file walk resolves to the right file URL.
Remaining tasks
Known limitation, not solved here: Canvas can only render a field through an SDC, and Vartheme BS5 ships no audio component. So inside the Canvas full template the local audio still renders through the video component (a video element in a 21:9 frame), and a remote-audio episode renders nothing there. A follow-up issue on Vartheme BS5 for a proper audio component is needed, alongside #3622961.
- ✅ File an issue
- ✅ Addition/Change/Update/Fix
- ✅ Testing to ensure no regression
- ❌ Automated unit/functional testing coverage
- ➖ Developer Documentation support
- ➖ User Guide Documentation support
- ➖ UX/UI designer responsibilities
- ➖ Accessibility and Readability
- ❌ Reviewed by a human
- ❌ Code review by maintainers
- ❌ Full testing and approval
- ❌ Credit contributors
- ❌ Review with the product owner
- ❌ Update Release Notes
- ❌ Release
User interface changes
- The episode form no longer offers two audio fields. It offers one Audio field with the Media Library widget, where the editor picks an Audio or a Remote audio media item.
API changes
- N/A
Data model changes
field_audioon the Podcast content type changes from a file field to an entity reference tomedia, targeting theaudioandremote_audiobundles.field_audio_urlis removed from the Podcast content type, both the field instance and its storage.- New dependency on
media.type.remote_audiofrom Varbase Media Base.
Release notes snippet
- A podcast episode now carries one Audio field referencing a media item, so an editor picks an uploaded audio file or a remote one from the media library instead of choosing between a file field and a link field. The Audio URL field is removed. Remote audio comes from Varbase Media Base.
Issue fork varbase_podcasts_base-3624729
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
rajab natshahMerged as aa09f0d and released in 1.0.0-alpha1: https://www.drupal.org/project/varbase_podcasts_base/releases/1.0.0-alpha1
An episode now has one Audio field referencing an Audio or Remote audio media item, and field_audio_url is gone. The missing audio component in Vartheme BS5 is still open, tracked in #3622961.