I've created a new podcast content type using the audiofield. My objective was to display a list of all the podcasts created in a table so I created a new view using the podcast content type I'd just created. It all looks fine except that the filesize is displayed as 0.0Kb in the view, but displayed properly in the node.

I aslo had to mess about with the formatting in the theme_audiofield() function in audiofield.module as a few of the fields were the wrong way around

Comments

a_c_m’s picture

Can you submit a patch or say what you needed to change to get it to work how you expected?

vivianspencer’s picture

Ok, here are the changes I made to audiofield.module

Previous:

function audiofield_field_formatter($field, $item, $formatter) {
  if (!isset($item['fid'])) {
    return '';
  }
  $file = _field_file_load($item['fid']);
  return theme('audiofield', $file, $item, $filed);
}

After:

function audiofield_field_formatter($field, $item, $formatter) {
  if (!isset($item['fid'])) {
    return '';
  }
	require_once(drupal_get_path('module', 'audiofield') .'/multimediafile.inc');
  $file = _field_file_load($item['fid']);
  return theme('audiofield', $file, $item, $filed);
}

Previous:

function theme_audiofield($file, $item, $field) {
    ....
    $item['filesize'] = format_filesize($item['filesize']);
    $url = l($name, file_create_url($path));

    $info = sprintf("<div> %s %s min %s %s (%s) </div>", $item['sample_rate'], $item['bitrate'], $url, $item['playtime'], $item['filesize']);

    return $info;
  }
}

After:

function theme_audiofield($file, $item, $field) {
    ....
    $file['filesize'] = format_filesize($file['filesize']);
    $url = l($name, file_create_url($path));

    $info = sprintf("<div> %s %s %s %s min (%s) </div>", $item['sample_rate'], $item['bitrate'], $url, $item['playtime'], $file['filesize']);

    return $info;
  }
}

The problem was that the filesize was not stored in the $item array but in the $file array.

I also found another problem in the following function:

function audiofield_field_formatter($field, $item, $formatter) {
  if (!isset($item['fid'])) {
    return '';
  }
  $file = _field_file_load($item['fid']);
  return theme('audiofield', $file, $item, $filed);
}

there's a spelling mistake on the return line, should be:

  return theme('audiofield', $file, $item, $field);
a_c_m’s picture

Thanks for that, looks good.

The type-o bug is now fixed, as are a selection of other bugs and there are also some new features in the latest release, you should try it out :) if you re-apply your changes and have some time, why not submit your changes as a patch? http://drupal.org/patch/create

Thanks a_c_m

a_c_m’s picture

Status: Active » Fixed

any patches for this?

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.