Reference

Guide

$page->hasAudio()

Checks if the Files collection has any audio files

$page->hasAudio(): bool

Return type

bool

Example

<?php
echo $page->hasAudio(); //will echo 1 if true, nothing if false

if($page->hasAudio()) {
  $audio = $page->audio();
}
?>

What is an audio file?

Kirby considers the following file types as audio files:

  • mp3
  • m4a
  • wav
  • aif
  • aiff
  • midi

Source code

kirby/src/Cms/HasFiles.php#L120