Sharing my first block (for audio-files)


I needed a block-field for mp3-files and had to code it myself. I thought a might as well give it back to the community (to be honest: I would love to see that as a default-block in Kirby 3.5.1 as this is probably very useful for many Kirby-users…). I hope this helps others in the community.

To the team behind Kirby: Please consider adding this to Kirby 3.5.x oder 3.6 :slight_smile:

# /site/blueprints/blocks/audio.yml
name: Audio-Datei
icon: file-audio
label: "{{ name }} - {{ creator }}"
    type: files
    type: text
    type: text

And here the corresponding PHP:

<div class="container">
  <audio controls>
    <source src="<?= $block->soundfile()->toFile() ?>" type="audio/mpeg">
    Your browser does not support the audio element.
  <div class="blockquote-footer p-3 ">
     <cite title="Source Title"><?= $block->name() ?></cite>

This looks like this in the end:

And this is how it looks rendered as HTML (using Bootstrap 5 on Windows 10 and Firefox):

1 Like

You can post your feature wishes on our feeback channel:

Thank you for reminding me: