Community Documentation

Add album Images to the teaser whis link to node

Last updated October 21, 2007. Created by namli on October 19, 2007.
Log in to edit this page.

Paste to template.php :

<?php
/**
* Format the teaser for an audio node.
*/
function phptemplate_audio_teaser($node){

 
// make sure that all the allowed tags are included.
 
foreach (audio_get_tags_allowed() as $tag) {
   
$params['!'. $tag] = isset($node->audio_tags[$tag]) ? check_plain($node->audio_tags[$tag]) : '';
  }
 
$params['!filelength'] = theme('audio_format_filelength', $node->audio_fileinfo);
 
$params['!fileformat'] = theme('audio_format_fileformat', $node->audio_fileinfo);
 
$params['!player'] = audio_get_node_player($node);
 
$params['!play_count'] = check_plain($node->audio_fileinfo['play_count']);
 
$params['!download_count'] = check_plain($node->audio_fileinfo['download_count']);
// this is start off edit
   
$params['!images']= theme('audio_images', $node->audio_images, $node->nid);
//and of edit
 
$format = variable_get('audio_teaser_format', '!player<br />!filelength');
  return
t($format, $params);
     }
function
phptemplate_audio_images($audio_images, $url) {
  if (
$image = audio_images_get($audio_images)) {

    return
"<div class='audio-image'>\n <a href=".url('node/'. $url).">". theme('audio_image', $image) ." </a>\n</div>\n";
  }
}

function
phptemplate_audio_display($node) {
 
$items = array();
  if (
$player = audio_get_node_player($node)) {
   
$items[] = $player;
  }
  foreach (
audio_get_tag_settings() as $tag => $setting) {
    if (!
$setting['hidden'] && $node->audio_tags[$tag]) {
     
$items[] = '<strong>'. t(ucwords(str_replace('_', ' ', $tag))). ':</strong> '
       
. theme('audio_format_tag', $tag, $node->audio_tags[$tag], $setting);
    }
  }
 
$items[] = '<strong>'. t('Length') .':</strong> '. theme('audio_format_filelength', $node->audio_fileinfo);
 
$items[] = '<strong>'. t('Format') .':</strong> '. theme('audio_format_fileformat', $node->audio_fileinfo);

 
$output = "<div class='audio-node block'>\n";
 
// give audio_image.module (or a theme) a chance to display the images.
 
$output .= theme('audio_images', $node->audio_images,$node->nid);
 
$output .= theme('item_list', $items, NULL, 'ul', array('class' => 'audio-info'));
 
$output .= "</div>\n";

  return
$output ;
}
?>

2. Go to http://www.yousite.com/admin/settings/audio
use !images in field "Node teaser format" for specification of an image place.

About this page

Drupal version
Drupal 5.x

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.