Adding token support to audio_image

trish t - January 26, 2007 - 18:25
Project:Audio
Version:6.x-1.x-dev
Component:audio_image
Category:feature request
Priority:minor
Assigned:Unassigned
Status:active
Description

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

#1

trish t - January 26, 2007 - 18:27

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);
}

#2

drewish - January 26, 2007 - 18:30
Version:5.x-0.1» 5.x-1.x-dev
Category:task» feature request
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.

#3

trish t - January 26, 2007 - 18:33

Yes. Thanks.

Should be easy enough for one line..

#4

drewish - January 26, 2007 - 18:42

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.

#5

trish t - January 26, 2007 - 19:33

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

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

#6

trish t - January 29, 2007 - 13:11

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

AttachmentSize
audio_theme.inc_.patch 713 bytes

#7

trish t - January 29, 2007 - 13:14

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.

AttachmentSize
audio.module_5.patch 985 bytes

#8

drewish - January 29, 2007 - 16:27

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').

#9

trish t - January 30, 2007 - 22:10

'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.

AttachmentSize
audio_0.patch 2.3 KB

#10

Carlos Miranda Levy - July 17, 2007 - 22:06

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.

#11

drewish - August 1, 2007 - 00:44
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.

#12

CinemaSaville - September 27, 2009 - 06:25

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

#13

riskyfuel - October 27, 2009 - 22:10
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!

 
 

Drupal is a registered trademark of Dries Buytaert.