Would it be possible to get the album art to show up in the teaser, like the video module? Right now I'm using image_attach to upload a duplicate image of the album art, and deleting the original. It would be great if I could just use the integrated album art!

Comments

drewish’s picture

i'd like to add support for that but in the mean time you could probably do it with your own theme function. i haven't tested this but it's basically a mash up of the theme_audio_teaser() and theme_audio_display() functions.

// override the colors on the flash player
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]) ? $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_player($node);
  $params['%play_count'] = $node->audio_fileinfo['play_count'];
  $params['%download_count'] = $node->audio_fileinfo['download_count'];

  // THE DIFFERENCE IS HERE
  // if there's an image, put it in as an %image parameter.
  if ($image = audio_images_get($audio_images)) {
    $params['%image'] = "<div class='audio-image'>\n" . theme('audio_image', $image) . "\n</div>\n";
  }
  // THAT'S IT

  $format = variable_get('audio_teaser_format', '%player %filelength');

  return t($format, $params) . $node->teaser;
}
CosmicVoyager’s picture

Thanks, that worked, except audio_images_get($audio_images) should be audio_images_get($node->audio_images).

drewish’s picture

Status: Active » Fixed

i've added this to a handbook page

Anonymous’s picture

Status: Fixed » Closed (fixed)
kevinbroome’s picture

Component: User interface » Miscellaneous

i've added the code from the handbook to /themes/mytheme/template.php

but the album art doesn't appear in the teaser.. is there anything else i need to do?

(sorry but i'm a bit of a beginner on drupal hacks/mods)

rajaito’s picture

Status: Closed (fixed) » Active

I am looking to do this for Drupal 6.

Any advice?

CinemaSaville’s picture

Subscribing

riskyfuel’s picture

I posted this in a related thread:

http://drupal.org/node/113073

For the 6.x version, just add a line for the image token in the formatted file info section near line 1353 of audio.module.

// Formatted file info.
    $tokens['audio-length'] = theme('audio_format_filelength', $node->audio);
    $tokens['audio-format'] = theme('audio_format_fileformat', $node->audio);
     $tokens['audio-image'] = theme('audio_images', $node->audio_images);

Then add the [audio-image] token into the Teaser settings in the Audio Settings admin section.

CinemaSaville’s picture

Version: 4.7.x-1.x-dev » 6.x-1.0-unstable5

Thanks, that worked well. Now how would I style it so the image appears underneath the other 2 fields?