🔔 Alert..!! Get 2 Month Free Cloud Hosting With $200 Bonus From Digital Ocean ACTIVATE DEAL

File Size is a jQuery plugin used to convert file size in bytes to human readable format (KB, MB, GB, TB, PB, etc).

file-size

Documentation

Usage

To use the filesize API simply init the filesize function on the selector of choice, for ex.

$("#element").filesize() 

If you prefer to apply to a broader selector

$(".fs").filesize() 

To use the function outside of the context of a selector

> $.fn.filesize._humanize(2000) > "1.95 kilobytes" 

Examples

  • 1999 becomes 1.95 kB
  • 5000000 becomes 488.28 kB
  • 6000000000 becomes 5.59 GB

See demo/index.html for more examples.

Ember

To use as a Helper in Ember:

  • bower install jquery-filesize
  • Add the script in the html
  • Add a helper in Ember
  Ember.Handlebars.helper 'bytes', (value, options) ->     humanReadable = $.fn.filesize._humanize(Handlebars.Utils.escapeExpression(value), {abbr: true})       return new Handlebars.SafeString('<span>' + humanReadable + '</span>') 

Contributing

  • fork the repo
  • npm install
  • grunt (which tests and packages)

You May Also Like