Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<?php // If there is audio content, print it with it's description.
if (isset($content['field_audio_file'])) {
// Hide so we can display it later.
print '<div class="field-item">';
// Loop through each audio file.
$audiofiles = $content['field_audio_file']['#items'];
foreach ($audiofiles as $delta => $audiofile) {
$uri = $audiofile['uri'];
$audiopath = file_create_url($uri); // Converts uri to path format.
print '<div class="audio-field">';
// If there is a description, display it.
if (isset($audiofile['description'])) {
print '<div class="label">' . $audiofile['description'] . '</div>';
// Display audio player.
print '<audio controls="controls"><source src="' . $audiopath . '" type="audio/mpeg" >
print '</div>';
} ?>
<div class="content">
<?php print render($content); // Render the rest of the node's fields. ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment