Not sure how to categorize this post-

I wanted my audio images to show in the teasers along with the node, so I added the variable '!imageo'
to the teaser function in audio_theme.inc beneath '!download_count'

 $params ['!imageo']= theme('audio_images', $node->audio_images);

Then on admin/settings/audio I included my variable !imageo after !player for the 'Node teaser format'

Result is here: http://radio.trishturliuk.ca/podcast

Trish

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brst t’s picture

Here's the entire function with my one line insertion:

/**
 * Format the teaser for an audio node.
 */
function theme_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']);
  $params ['!imageo']= theme('audio_images', $node->audio_images);
  $format = variable_get('audio_teaser_format', '!player !filelength');

  return t($format, $params);
}
drewish’s picture

Version: 5.x-0.1 » 5.x-1.x-dev
Category: task » feature
Status: Active » Needs work

Take a look at http://drupal.org/patch it describes how to submit a proper patch. It makes reviewing the changes your proposing much easier.

brst t’s picture

Yes. Thanks.

Should be easy enough for one line..

drewish’s picture

well the thing about patches is that it makes it very clear that you're only changing on line. looking at a block like that it's hard to know what's new, what's changed and what's been removed.

brst t’s picture

Yep. Especially if there's more than one line changed.

I've used them. I just haven't submitted any, yet.

brst t’s picture

FileSize
713 bytes

Here's the first - the change to the theme, adding image as a variable to the teaser format

brst t’s picture

FileSize
985 bytes

And the second - to show in audio admin settings that this variable is available, but not set in the default.

First submitted patches, here. One liners w/o the humour.

drewish’s picture

I'm not sure what program you're using to generate the patch files but you can probably combine changes to multiple files in one patch.

The one problem with the patches you've provided is that there's no check that the audio_image module is enabled. I don't think the the $node->audio_images array will be defined if it's not. That'll cause errors/warnings. You can check if it's enabled using module_exists('audio').

brst t’s picture

FileSize
2.3 KB

'Combine changes to multiple files in one patch'

Got it. Ok. Thanks. (Missed that part somewhere.)

Also included in this attachment are the changes I made to the css file - the image div setting a border and float:right

The one problem with the patches you've provided is that there's no check that the audio_image module is enabled. I don't think the the $node->audio_images array will be defined if it's not. That'll cause errors/warnings. You can check if it's enabled using module_exists('audio').

I tested my changes by removing the audio_images module and didn't get any errors/warnings. The images simply didn't show.

The changes I made are similar to the full node 'theme_audio_display' function just below. I don't see a check if the module is enabled there, either.

Or maybe you mean for the module? If so, I think that could be changed w/ a little note in the description.

Carlos Miranda Levy’s picture

There is another alternative which may not break as easily when you upgrade the module to a new version.

Look at the template.php approach at: http://drupal.org/node/84162

Basically, all you do is create a template.php with a replacement for the function affected and put that template.php in your current theme´s directory.

drewish’s picture

Title: Adding image as variable for 'Node teaser format' » Adding token support to audio_image
Version: 5.x-1.x-dev » 5.x-2.x-dev
Status: Needs work » Active

Now that the 5.x-2.x code use the token module for building teasers and titles the way to do this is by adding token support to audio_image.module.

CinemaSaville’s picture

Did this ever get done? Trying to use it for 6?

riskyfuel’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev

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.

Rock!

Frank Ralf’s picture

Status: Active » Needs review
FileSize
1.36 KB

I created a proper patch from the modification suggested in #13. Just added another line for hook_token_values() so the new token also shows up in the list of available tokens.

Frank