I created a view with different fields, one of them being the duration of an emfield.
The view allow to hide a field if it is empty. If you display the field in seconds ( ss ), it works but if you decide to show the field as mm:ss, the field still show up with 00:00 as data.

Where does this bug goes ?

Comments

CinemaSaville’s picture

I've got the same issue.

discipolo’s picture

Project: Embedded Media Field » FileField
Version: 6.x-1.9 » 6.x-3.2
Component: Miscellaneous » Code
Category: bug » task

i had the same.
added a theme function in template.php to make filefield_meta display '0' instead of '0:00' so views recognizes it and hides it.
taken from (api.lullabot.com/theme_filefield_meta_duration)

/* set duration to 0 if empty*/
function MYTheme_filefield_meta_duration($duration) {
$seconds = round((($duration / 60) - floor($duration / 60)) * 60);
$minutes = floor($duration / 60);
if ($seconds >= 60) {
$seconds -= 60;
$minutes++;
}
if($seconds == 0 && $minutes == 0) {return 0 ;}else{
return intval($minutes) . ':' . str_pad($seconds, 2, 0, STR_PAD_LEFT);}
}

quicksketch’s picture

Hm, interesting, that seems like something that should be taken into account in the Views handler for duration. Actually it may be taken into account already in the 3.3 version, which fixed a bunch of problems in FileField Meta.

discipolo’s picture

hm... doesnt seem fixed in 3.3 version as far as i can tell but the error is different. (duration is hidden and handled as empty even if it has content)

quicksketch’s picture

Status: Active » Closed (fixed)

I can't reproduce this problem in 3.3 and higher. We currently have this code in place:

    // Check to see if hiding should happen before adding prefix and suffix.
    if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) {
      return '';
    }

So this means that a value of "0" will not be show if you have the "Count the number 0 as empty" option checked. If the value is NULL or an empty string, the field will be hidden as long as "Hide if empty" is checked.

Please open a new issue if there is a different problem regarding duration display, but my testing indicates this problem is already corrected.