In my incessant need to enhance The-Nexus website, my attention fell today to the sidebar with the Power Press player. On any given episode, the player sits on the right side of the page in a relatively narrow 380 pixel column. Below the player itself, there is a pop out link which opens the player in a separate window and then a download link for direct downloads, it works either way. But the problem I have been facing for eons now is how to exactly display the episode size and duration (what I call episode length, but call it whatever you like). So today, I dove into the Power Press code to figure it out.
Here’s what the sidebar looked like previously.

In the powerpress.php
file around 2131, you’ll find a great function called powerpress_get_enclosure_data
. Basically, it gets any metadata it has on your audio file (or whatever you somehow use Power Press for) and put it all in a neatly labeled array. It just requires a post ID to pull the data from and it’ll return everything it knows, which just happens to be the filesize and length of a file.
In my theme, I display the player and such with something like this:
<?php
echo '<h3>Listen</h3>';
echo get_the_powerpress_content();
$values = powerpress_get_enclosure_data(get_the_ID());
?>
<div class="download-meta">
<span class="show-size"><?php echo convergence_display_size($values); ?></span>
•
<span class="show-length"><?php echo convergence_display_length($values); ?></span>
</div>
Everything there is simple enough. The get_the_powerpress_content
display the player, pop out and download link. The code below that is the custom code I wrote to fetch and display the size and length of the episode near to the player for convienece.
First, I wrote two simple Convergence methods (Convergence is the theme, after all) to handle the displaying of those values.
function convergence_display_size($values) {
if (!$values || !isset($values['size'])) return '';
return _human_filesize($values['size']);
}
function convergence_display_length($values) {
if (!$values || !isset($values['duration'])) return '';
return _human_length($values['duration']);
}
Without knowing for sure that the $values
array would be filled in (since I didn’t write the code for Power Press and I don’t know what conditions might break it), I decided to just return early if the array was empty or missing the value I wanted. Then each function respectively call a helper function for its purpose.
_human_filesize
was basically publicly available code which I adapted.
function _human_filesize($size) {
$base = 1024;
$sizes = array('B', 'KB', 'MB', 'GB', 'TB');
$place = 0;
for (; $size > $base; $place++) {
$size /= $base;
}
return round($size, 2) . ' ' . $sizes[$place];
}
_human_length_
follows the Power Press convention for storing file durations (which I call lengths). The format is hour:minute:seconds, but the seconds granularity was not really needed for what I was using this for, so I simply looped one less time.
function _human_length($length) {
/* this works for standard powerpress times 01:23:45 | hour | minute | second */
$parts = explode(':', $length);
$times = array( array('hour', 'hours'), array('minute', 'minutes'), array('second, seconds') );
$output = '';
/* ignore seconds */
for ($i = 0; $i < 2; $i++) {
$value = (int)$parts[$i];
$word = ( $value == 1 ? $times[$i][0] : $times[$i][1] );
$output = $output . ($value . ' ' . $word . ' ');
}
return trim($output);
}
The trim at the end ensures that the last concatenation doesn’t drip an extra whitespace onto the output.
From there, I styled the output to taste and I came up with the revised sidebar presentation. I made the margins smaller, made the file meta-information tiny, and made the player the full width of the sidebar.

While this was not a huge task, the Power Press documentation is a little lacking and the code is a little chaotic. While there is the obvious Power Press shortcode powered by powerpress_get_enclosure_data
somewhere, there are no shortcodes or direct methods to show the ID3 data and generic file data of these files. Adding these two additional pieces of information, the episode filesize and episode length really helps to flesh out the player area in the sidebar.