You are here

function _video_size2bytes in Video 5

Same name and namespace in other branches
  1. 6 video.module \_video_size2bytes()
  2. 6.2 video.module \_video_size2bytes()

Convert filesize to bytes

Return value

integer bytes

File

./video.module, line 1174
Display video in Quicktime MOV, Realmedia RM, Flash FLV & SWF, or Windows Media WMV formats.

Code

function _video_size2bytes($node) {
  if (!empty($node->size)) {
    switch ($node->size_format) {
      case 'Kb':

        // KiloBits
        return intval($node->size * 128);
        break;
      case 'KB':

        // KiloBytes
        return intval($node->size * 1024);
        break;
      case 'Mb':

        // MegaBits
        return intval($node->size * 131072);
        break;
      case 'MB':

        // MegaBytes
        return intval($node->size * 1048576);
        break;
      case 'Gb':

        // GigaBits
        return intval($node->size * 134217728);
        break;
      case 'GB':

        // GigaBytes
        return intval($node->size * 1073741824);
        break;
      default:
        return (int) $node->size;
        break;
    }
  }
  else {
    return 0;
  }
}