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
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
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
Yes. Thanks.
Should be easy enough for one line..
#4
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
Yep. Especially if there's more than one line changed.
I've used them. I just haven't submitted any, yet.
#6
Here's the first - the change to the theme, adding image as a variable to the teaser format
#7
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.
#8
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
'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
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.
#10
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
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
Did this ever get done? Trying to use it for 6?
#13
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!